-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvehicle.py
57 lines (46 loc) · 1.66 KB
/
vehicle.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
47
48
49
50
51
52
53
54
55
56
from blinker import *
from fuel import *
from engine import *
from light import *
from environment import *
class Vehicle:
def __init__(self):
self.blinker_front = Blinker(BLINKER_FRONT)
self.blinker_rear = Blinker(BLINKER_REAR)
self.engine = engine()
self.fuel = fuel(self.engine)
self.environment = environment()
self.light = light(self.environment)
def __str__(self):
status ='front blink: ' + str(self.blinker_front)+ ' ' + 'rear blink: '+ str(self.blinker_rear) + '\n'+ str(self.engine) + '\n' + str(self.environment) + '\n' + str(self.fuel) + '\n' + str(self.light) + '\n'
return status
def do_work(self):
while True:
print(self)
key = input('next action (q quit): ')
if key == 's':
self.blinker_front.change()
print(self.blinker_front)
if key == 'a':
self.blinker_rear.change()
print(self.blinker_rear)
if key == 'w':
self.engine.modify_rpm(100)
print(self.engine)
if key == 'z':
self.engine.modify_rpm(-100)
if key == 'e':
self.engine.modify_gear(1)
if key == 'd':
self.engine.modify_gear(-1)
if key == 'r':
self.environment.modify_lum(10)
if key == 'f':
self.environment.modify_lum(-10)
if key == 'q':
exit()
self.light.update()
self.fuel.update()
if __name__ == "__main__":
vehicle1 = Vehicle()
vehicle1.do_work()