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.
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..
|