self.baseFare = fare def __str__(self): s = “Name: ”+self.name+", Base fare: "+str(self.baseFare) return s # Write your codes here. # Do not change the following lines of code. t1 = Bus(“Volvo”, 950) print("=================================") t1.addPassengerWithBags(“David”, 6, “Mike”, 1, “Carol”, 3) print("=================================") print(t1) print("=================================")
write python coiide within 30 minutes
Design Bus class and Train class which inherit Transport class so that the
following code provides the expected output. [addPassengerWithBags() method
should work any number of parameters assuming that the parameter number
will be an even number and greater than 1]
Note: A passenger can carry upto 2 bags for free. 60 taka will be added if
the number of bags is between 3 and 5. 105 taka will be added if the number
of bags is greater than 5.
class Transport:
total_traveller = 0
def __init__(self, name, fare):
self.name = name
self.baseFare = fare
def __str__(self):
s = “Name: ”+self.name+", Base fare: "+str(self.baseFare)
return s
# Write your codes here.
# Do not change the following lines of code.
t1 = Bus(“Volvo”, 950)
print("=================================")
t1.addPassengerWithBags(“David”, 6, “Mike”, 1, “Carol”, 3)
print("=================================")
print(t1)
print("=================================")
t2 = Train(“Silk City”, 850)
print("=================================")
t2.addPassengerWithBags(“Bob”, 2, “Simon”, 4)
print("=================================")
print(t2)
print("=================================")
print(“Total Passengers in Transport: ”, Transport.total_traveller )
OUTPUT:
Base-fare of Volvo is 950 Taka
===============================
===============================
Name: Volvo, Base fare: 950
Total Passenger(s): 3
Passenger details:
Name: David, Fare: 1055
Name: Mike, Fare: 950
Name: Carol, Fare: 1010
===============================
Base-fare of Silk City is 850 Taka
===============================
===============================
Name: Silk City, Base fare: 850
Total Passenger(s): 2
Passenger details:
Name: Bob, Fare: 850
Name: Simon, Fare: 910
===============================
Total Passengers in Transport: 5
Step by step
Solved in 2 steps