Create a ride share simulator assignment

Assignment Help Python Programming
Reference no: EM13987408

Create a ride share simulator assignment. In this particular function, I am trying to create a list of the drivers in a Driver Class that are currently listed as idle. Since they are idle, I can then match them up with an awaiting rider. The assignment dictates that I must find the closest driver to the rider, so this is my code:

def request_driver(self, rider):
"""Return a driver for the rider, or None if no driver is available.

Add the rider to the waiting list if there is no available driver.

@type self: Dispatcher
@type rider: Rider
@rtype: Driver | None
"""
availdriver = []
for driver in self.driverlist:
if driver[1] == True:
availdriver.append(driver[0])

if len(availdriver) == 0:
return None
self.waitlist.append(rider)
elif len(availdriver) == 1:
return availdriver[0]
else:
nearest = availdriver[0]
for i in range(len(availdriver)):
if availdriver[i].get_travel_time(rider.origin) nearest = availdriver[i]
return nearest

 

(this text box isn't amenable to tabbing so pretend it's properly indented)

So because I am saving instances of a class into a list, when I read out the list, they are bring read as string objects. do you know a way around this?

 

This is the code responsible for producing driverlist

def request_rider(self, driver):
"""Return a rider for the driver, or None if no rider is available.

If this is a new driver, register the driver for future rider requests.

@type self: Dispatcher
@type driver: Driver
@rtype: Rider | None
"""
if driver.id not in self.driverlist:
self.driverlist.append([driver.id, driver.is_idle])
if len(self.waitlist) == 0:
return None
else:return self.waitlist.pop(0)

 

this is a first year computer class so if I used any advanced functions it would look very fishy.

 

Reference no: EM13987408

Questions Cloud

These are only two examples of the multiple technological : These are only two examples of the multiple technological improvements made by the DHS to support the QHSR initiative of effectively securing U.S. air, land, and sea borders.
What is the messimer''s final tax : What is the Messimer's final tax that should be paid with their return for 2015?
How much heat energy is transferred to or from the system : A block of aluminum is 7cm x 5cm x 5cm. The initial temperature of the aluminum is -30oC. How much heat must you add to bring the block temperature up to 30oC?
How much would erica receive as a refund from her 2015 taxes : Erica paid $6,000 toward tuition at Heartland College for Randall during 2015. Erica will contribute the maximum deductible amount to her IRA for 2015 and is a participant in her employer's pension plan.
Create a ride share simulator assignment : Create a ride share simulator assignment. In this particular function, I am trying to create a list of the drivers in a Driver Class that are currently listed as idle. Since they are idle, I can then match them up with an awaiting rider. The assignme..
What distance from the unstrained position is the speed : The block is pulled away from the spring's unstrained position by a distance x0 = 0.050 m and released from rest. The period of the subsequent periodic motion of the block is 0.64 s. At what distance from the unstrained position is the speed of the b..
Is doe guilty of the possession charge : Is Doe guilty of the possession charge? Fully explain the basis of your position. What facts not provided in this case would you want to know in order to determine guilt
What distance from the unstrained position is the speed : The block is pulled away from the spring's unstrained position by a distance x0 = 0.050 m and released from rest. The period of the subsequent periodic motion of the block is 0.64 s. At what distance from the unstrained position is the speed of the b..
Which stores and manipulates times on a 24 hour clock. : Complete the class Time, which stores and manipulates times on a 24 hour clock. As specified below, write the required methods, including those needed for overloading operators. Exceptions messages should include the class and method names, and ident..

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd