-
Notifications
You must be signed in to change notification settings - Fork 0
/
car_class.py
46 lines (33 loc) · 1.09 KB
/
car_class.py
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
39
40
41
42
43
44
45
46
#You are to create a Car class that can be used to instantiate various vehicles.
#It takes in arguments that depict the type, model, and name of the vehicle, provided they are set.
class Car(object):
def __init__(self, name='General', model='GM' ,car_type='honda' ):
self.car_type = car_type
self.model = model
self.name = name
self.speed = 0
if name== 'Porshe' or name== 'Koenigsegg':
self.num_of_doors = 2
else:
self.num_of_doors = 4
if car_type == 'trailer':
self.num_of_wheels = 8
else:
self.num_of_wheels = 4
def doors(self, num_of_doors):
pass
def drive(self, moving_man):
return moving_man
def drive(self, spd):
if self.car_type == 'trailer':
self.speed = spd * 11
else:
self.speed = 10 ** spd
return self
def wheels(self, num_of_wheels):
return num_of_wheels
def is_saloon(self):
if self.car_type == 'trailer':
return False
else:
return True