Last active
March 6, 2022 17:46
-
-
Save okanyenigun/7b7498d826094604cc42002ddd811bbb to your computer and use it in GitHub Desktop.
abstract_class_example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from abc import ABC, abstractmethod | |
class Vehicle(ABC): | |
@abstractmethod | |
def go(self): | |
pass | |
@abstractmethod | |
def stop(self): | |
pass | |
def open_doors(self): | |
print("Doors opened") | |
class Car(Vehicle): | |
#overriding abstract method | |
def go(self): | |
print("Gone") | |
#overriding abstract method | |
def stop(self): | |
print("Stopped") | |
Bmw = Car() | |
Bmw.open_doors() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment