Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python Complete the Van class such that the following code snippet works as expected when called by the test program. A shuttle van picks up

python

image text in transcribed

Complete the Van class such that the following code snippet works as expected when called by the test program. A shuttle van picks up passengers and drives them to a destination, where they leave the van. Keep a count of the boarding passengers and do not allow more passengers to board than the van can hold. For example, if there are already 2 people on the van that has a maximum capacity of 8. Then even though 7 more people may want to sit in van, only 6 more people can fit in it. Update the odometer when the van drives. Submit the completed van.py that contains the van class. You do not need to submit the test program vantest.py # van.py ## This class models a shuttle van class Van ## Constructs a van with a given capacity # @param maxPassengers the maximum number of passengers that this def init slf, maxPassengers) ## Boards passengers up to the capacity of this van van can hold # @param board.ngPassengers the number of passengers attempting to board def board(self, boardingPassengers) ## Drives the van and discharges the passengers # @param distance the distance driven def drive (self, distance) ## Gets the number of passengers in this van # @return the number of passengers def getPassengers (self) ## Gets the number of miles that this van has driven @return the number of miles def getMilesDriven (self): Note: This is the tester/driver of the Van class. You do not need to modify this file # vantest.py from van import Van def main ) van1 Van(8) van1.board (3) print (van.getPassengers (), end-t" print ("Expected: 3") van1.board (6) print (van1.getPassengers (), end-t" print ("Expected: 8 van1. drive (10) print (van1.getPassengers(), endt" print ( "Expected: 0") print (van1.getMilesDriven ) end-t" print("Expected : 10") van1.board (6) print (van.getPassengers (), end-t") print ("Expected: 6) van1.drive (12) print (van1.getPassengers(), end-t" print("Expected: 0*) print (van1.getMilesDriven (), end\t" print ("Expected: 22") main ()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases A Tour

Authors: Shashi Shekhar, Sanjay Chawla

1st Edition

0130174807, 978-0130174802

More Books

Students also viewed these Databases questions

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago