Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Vehicle():
- def __init__(self, vehicleType, weight, seats):
- self.vehicleType = vehicleType
- self.weight = weight
- self.seats = seats
- def showInfo(self):
- print('type: {}, weight(in ton): {}, seat number: {} '.format(self.vehicleType, self.weight, self.seats))
- class Car(Vehicle):
- def __init__(self, vehicleType, weight, seats):
- self.vehicleType = vehicleType
- self.weight = weight
- self.seats = seats
- class Bike(Vehicle):
- def __init__(self, vehicleType, weight, seats):
- self.vehicleType = vehicleType
- self.weight = weight
- self.seats = seats
- c = Car('car', 200, 10)
- b = Bike('bike', 50, 3)
- allVehicles = [c, b]
- for i in allVehicles:
- i.showInfo()
Add Comment
Please, Sign In to add comment