-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCar Class.py
More file actions
38 lines (25 loc) · 930 Bytes
/
Car Class.py
File metadata and controls
38 lines (25 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from sys import stdin
class Car:
#Write your constructor and printCarInfo method here.
def __init__(self, noOfGear = 5, color = 'red'):
self.noOfGear = noOfGear
self.color = color
def printInfo(self):
print('noOfGear: ',self.noOfGear)
print('color: ', self.color)
class RaceCar(Car):
#Write your constructor and printRaceCarInfo method here.
def __init__(self, noOfGear = 5, color = 'red', maxSpeed = 1000):
self.noOfGear = noOfGear
self.color = color
self.maxSpeed = maxSpeed
def printInfo(self):
print('noOfGear:',self.noOfGear)
print('color:', self.color)
print('maxSpeed:', self.maxSpeed)
#Driver's code
noOfGear = int(stdin.readline().rstrip())
color = stdin.readline().rstrip()
maxSpeed = int(stdin.readline().rstrip())
raceCar = RaceCar(noOfGear,color,maxSpeed)
raceCar.printInfo()