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 an expression whose value is the concatenation

Write an expression whose value is the concatenation of the three str values associated with name1, name2, and name3, separated by commas. So if name1, name2, and name3, were (respectively) "Neville", "Dean", and "Seamus", your expression's value wou..

  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 a python program that starts from the starting state

Task consists of programming a Python implementation of a solver for the Desert Crossing Task - write a Python program that starts from the starting state.

  What is the purpose of variable fragnum

What is the purpose of variable fragNum in rdt1.0 sender code and how is the segmented message merged back in receiver? Which operation justifies it?

  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.

  Create a cheat commands in the game so player can teleport

Create a cheat commands in the game so player can teleport to any location in the map - The first four tasks in this section can be completed by modifying only the code within the ProcessStatement() and Game() functions. This section typically requ..

  Calculate the total displacement of the system of springs

Calculate the total displacement of the system of springs - You are free to use any linear system solver from chapter 6, including the solvers that are part of the SciPy and/or numpy packages.

  Fill in the python code

Fill in the Python code to play Tic Tac Toe. I won't award points unless it runs succesfully. # Tic-Tac-Toe Game def drawBoard(board): # Draws the board using the list of numbers print(" ") print(" ",board[0]," | ",board[1]," | ", board[2]) print("--..

  Write a function trans(m) which returns the transpose

Write a function trans(M) which returns the transpose of an n-by-n matrix M. The matrix M is represented by a list of n lists, each of length n. Transposing M means that each M[i][j] is swapped (once!) with M[j][i].

  Given the strings s1 and s2 that are of the same length

Given the strings s1 and s2 that are of the same length, create a new string consisting of the first character of s1 followed by the first character of s2, followed by the second character of s1, followed by the second character of s2, and so on (in ..

  The interest rate per period

The interest rate per period. For example, if your loan's interest is 6.5% per year, and you are paying monthly, this would be 6.5%/12. If you are paying every two weeks, r would be 6.5%/26, because there are 26 two-week periods in a year.

  Write a program using the ''requetinteger''

using python/jython programming write a program using the 'requetInteger' function that will ask the user to type a value that will draw a line from one point on a picture to another. I don't need specific help just a gerneral idea.

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