Skip to content

Commit 726544c

Browse files
Create abstractmethod.py
1 parent b977a5c commit 726544c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from abc import ABC, abstractmethod
2+
class Vehicle(ABC):
3+
@abstractmethod
4+
def go(self):
5+
pass
6+
class Car(Vehicle):
7+
def go(self):
8+
print("Car")
9+
class motorCycle(Vehicle):
10+
def go(self):
11+
print("Bike")
12+
13+
car = Car()
14+
motor = motorCycle()
15+
car.go()
16+
motor.go()
17+
car.stop()
18+
motor.stop()

0 commit comments

Comments
 (0)