-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathclass26.py
More file actions
58 lines (46 loc) · 1.09 KB
/
class26.py
File metadata and controls
58 lines (46 loc) · 1.09 KB
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
58
from abc import ABC,abstractmethod
# class Vehicle(ABC):
# @abstractmethod
# def start_car(self):
# pass
# class Tesla(Vehicle):
# def break_car(self):
# print("Car is slowing down.")
# def start_car(self):
# print("Starting the car")
# class BMW(Vehicle):
# def sports_mode(self):
# print("Sports mode is on.")
# def start_car(self):
# pass
# mytesla = Tesla()
# mytesla.break_car()
# mybmw = BMW()
# mybmw.sports_mode()
class Vehicle(ABC):
@abstractmethod
def back_light(self):
pass
# @abstractmethod
def windows(self):
print("this car has 4 windows.")
class Tesla(Vehicle):
def __init__(self):
self.model = "S3"
self.mileage = 65
self.speeed = 110
self.wheels = 4
self.ev = True
def horn(self):
print("Beep Beep")
def back_light(self):
print("YELLOW LIGHT")
class Toyota(Vehicle):
def back_light(self):
pass
mycar = Tesla()
print(mycar.ev)
mycar.horn()
mycar.windows()
mycar.back_light()
mytoyota = Toyota()