-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPythonProgram177.py
More file actions
21 lines (20 loc) · 904 Bytes
/
PythonProgram177.py
File metadata and controls
21 lines (20 loc) · 904 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
"""Class Inheritance Given:
Create a Bus child class that inherits from the vehicle class. The default fare charge of any vehicle is seating capacity*100.
If Vehicle is Bus instance, we need to add an extra 10% on full fare as a maintenance charge.
So total for bus instance will become the final amount = total fare +10% of the total fare.
Note: the bus seating capacity is 50. so the final amount should be 5500. You need to override the fare() method of a Vehicle class in Bus class.
"""
class Vehicle:
def __init__(self, name, mileage, capacity):
self.name = name
self.milege = mileage
self.capacity = capacity
def fare(self):
return self.capacity * 100
class Bus(Vehicle):
def fare(self):
amount=super().fare()
amount+=amount*0.1
return amount
School_bus = Bus("School Volvo",12, 50)
print("Total Bus fare is:",School_bus.fare())