In this program, we are implementing the concept of Abstraction using Abstract Class. Here, VEHICLE is Abstract Class and CAR and BIKE are Child Classes. VEHICLE class have two unimplemented methods, which are implemented in child Classes.
#Abstract Class
class Vehicle:
def start(self,name=""):
print(name,"is Started")
def acclerate(self,name=""):
pass
def park(self,name=""):
pass
def stop(self,name=""):
print(name,"is stopped")
class Bike(Vehicle):
def acclerate(self, name=""):
print(name,"is accelrating @ 60kmph")
def park(self, name=""):
print(name,"is parked at two wheeler parking")
class Car(Vehicle):
def acclerate(self, name=""):
print(name,"is accelrating @ 90kmph")
def park(self, name=""):
print(name,"is parked at four wheeler parking")
def main():
print("Bike Object")
b=Bike()
b.start("Bike")
b.acclerate("Bike")
b.park("Bike")
b.stop("Bike")
print("\nCar Object")
c = Car()
c.start("Car")
c.acclerate("Car")
c.park("Car")
c.stop("Car")
if __name__=="__main__":main()
Output
Bike Object
Bike is Started
Bike is accelrating @ 60kmph
Bike is parked at two wheeler parking
Bike is stopped
Car Object
Car is Started
Car is accelrating @ 90kmph
Car is parked at four wheeler parking
Car is stopped
Program:
Output
need an explanation for this answer? contact us directly to get an explanation for this answer