Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

If your class implementations are correct, the program produce the following output: - Object creation Car object 1 created: car 1 , ( 2 ,

If your class implementations are correct, the program produce the following output:
-Object creation
Car object 1 created: car1,(2,1),0.61
Car object 2 created: [car2,(-4,1),0.5
Passenger object 1 created: [passenger 1,(-2,3)]
Passenger object 2 created: [passenger2,(0,0)]
Scenario 1
Cheapest car available: car2, Cost per mile: 0.5
Cheapest car available: car2, Cost per mile: 0.5
Nearest car for passenger1: car2, Distance: 2.83
Nearest car for passenger2: car1, Distance: 2.24
-Scenario 2-
car1's location has been updated: [car1,(0,-5),0.61]
passenger 1's location has been updated: [passenger 1,(0,3)]
Cheapest car available: car2, Cost per mile: 0.5
Cheapest car available: car2, Cost per mile: 0.5
Nearest car for passenger1: car2, Distance: 4.47
Nearest car for passenger2: car2, Distance: 4.12
-Scenario 3-
New car added: [car3,(0,2),0.3
Cheapest car available: car3, Cost per mile: 0.3
Cheapest car available: car3, Cost per mile: 0.3
Nearest car for passenger 1: car3, Distance: 1.00
Nearest car for passenger2: car3, Distance: 2.00
import math
class Location:
#TODO: Implement the Location class according to the given UML class diagram and descriptions
class Car:
#TODO: Implement the Car class according to the given UML class diagram and descriptions
class Passenger:
#TODO: Implement the Passenger class according to the given UML class diagram and descriptions
class RideSharingApp:
#TODO: Implement the RideSharingApp class according to the given UML class diagram and descriptions
#For the remaining code (after this line), no modification is required
print ('-_-_object creation
location1= Location (2,1)
location2= Location (-4,1)
car1= Car('car1', location1,0.61)
car2, location2,0.50)
print('Car object 1 created: ', car1)
print('Car object 2 created:', car2)
location3= Location (-2,3)
location 4= Location (0,0)
passenger1= Passenger passenger 1', Location3)
passenger2= Passenger ('passenger2', location4)
print ('Passenger object 1 created: ', passenger1)
print ('Passenger object 2 created:'', passenger2)
mobileApp = RideSharingApp()
mobileApp.add_car(car1)
mobileApp.add_car(car2)
mobileApp.add_passenger (passenger 1)
mobileApp.add_passenger(passenger 2)
mobileApp. find_cheapest_car()
mobileApp.find_cheapest_car()
mobileApp.find_nearest_car(passenger1)
mobileApp.find_nearest_car(passenger 2)
car1.move_to (0,-5)
passenger1.move_to (0,3)
print ('car1's location has been updated:', car1)
print('passenger1's location has been updated:', passenger1)
mobileApp.find_cheapest_car()
mobileApp.find_cheapest_car()
mobileApp.find_nearest_car(passenger 1)
mobileApp.find_nearest_car(passenger2
car3, Location (0,2),0.3
mobileApp.add_car(car3)
print ('New car added: ', car3)
mobileApp.find_cheapest_car()
mobileApp. find_cheapest_car()
mobileApp.find_nearest_car(passenger1)
mobileApp.find_nearest_car(passenger 2)
image text in transcribed

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

Students also viewed these Databases questions