-
Notifications
You must be signed in to change notification settings - Fork 1
/
22.py
43 lines (31 loc) · 1021 Bytes
/
22.py
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
import abc
class Car:
def __init__(self, make, model, price):
self.make = make
self.model = model
self.price = price
def __str__(self):
return "Make: " + self.make + ", Model: " + self.model + ", Price: " + str(self.price)
@abc.abstractmethod
def show_details(self):
print("This calls the base class")
class Maruti(Car):
def __init__(self, model, price):
Car.__init__(self, "Maruti", model, price)
def __str__(self):
return super(Maruti, self).__str__()
def show_details(self) :
print ("You are in Sub Class - 1 ")
class Santro(Car):
def __init__(self, model, price):
Car.__init__(self, "Hyundai", model, price)
def __str__(self):
return super(Santro, self).__str__()
def show_details(self) :
print ("You are in Sub Class - 2")
maruti = Maruti("WagonR", 4500000)
santro = Santro("Santro", 3500000)
print(maruti)
print(santro)
maruti.show_details()
santro.show_details()