/
main.py
57 lines (44 loc) · 1.82 KB
/
main.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
57
from tesla import Tesla
from zero import Zero
from cessna import Cessna
from mb import MB
# Practice: Custom Colors and Sounds
# Define 5 of your favorite vehicles
# car1 = {"make": Porsche, "color": "Black", top_speed=140 }
# car2 = {"make": Jaguar, "color": "Gray", top_speed=100 }
# car3 = {"make": Audi, "color": "Red", top_speed=110}
# car4 = {"make": BMW, "color": "White", top_speed=120}
# car5 = {"make": Subaru, "color": "Blue", top_speed=200}
# Move all common properties in your vehicles to a new Vehicle class.
# class Vehicle:
# def __init__(self, make, color, top_speed, wheels=4):
# self.wheels = wheels
# self.make = make
# self.color = color
# self.top_speed = top_speed
# def drive(self):
# print(f"I'm driving in my {self.make} La la la la la")
# Create an instance of each vehicle.
# Define a different value for each vehicle's properties.
# car1 = Vehicle("Porsche", "Black", 140)
# car2 = Vehicle("Jaguar", "Gray", 100)
# car3 = Vehicle("Audi", "Red", 110)
# car4 = Vehicle("BMW", "White", 120)
# car5 = Vehicle("Subaru", "Blue", 200)
# Create a drive() method in the Vehicle class.
# Override the drive() method in all the other vehicle classes. Include the vehicle's color in the message (i.e. "The blue Ram drives past. RRrrrrrummbbble!").
# Create a turn(self, direction) method, and a stop(self) method on Vehicle. Define a basic implementation of each.
# Override all three of those methods on some of the vehicles. For example, the stop() method for a plane would be to output the message "The white Cessna rolls to a stop after rolling a mile down the runway."
# Make your vehicle instances perform all three behaviors.
model_s = Tesla()
fxs = Zero()
mx410 = Cessna()
e350 = MB()
model_s.drive()
fxs.drive()
mx410.drive()
e350.drive()
fxs.turn("left")
fxs.stop()
e350.turn("left")
fxs.stop()