-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAstractClasse.py
More file actions
37 lines (29 loc) · 803 Bytes
/
Copy pathAstractClasse.py
File metadata and controls
37 lines (29 loc) · 803 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
# Prevents a user from creating an object of that class
# + comples a user to override abstract methods in a child class
# abstract class = A class which contains one or more abstract methods
# abstract method = a method that has a declaration but does not have an implementation.fr
from abc import ABC, abstractmethod
class Vehicle(ABC):
@abstractmethod
def go(self):
pass
@abstractmethod
def stop(self):
pass
class Bike(Vehicle):
def go(self):
print("You ride the bike .")
def stop(self):
print("this Bike is stopped")
class Car(Vehicle):
def go(self):
print("You drive the car")
def stop(self):
print('this car is stopped')
car = Car()
bike = Bike()
# truck = Truck()
car.go()
bike.go()
bike.stop()
car.stop()