-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinheritance.py
More file actions
24 lines (21 loc) · 792 Bytes
/
inheritance.py
File metadata and controls
24 lines (21 loc) · 792 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
class Parent():
def __init__(self, last_name, eye_color):
print("Parent Constructor Called")
self.last_name = last_name
self.eye_color = eye_color
def show_info(self):
print("Last Name - "+self.last_name)
print("Eye Color - "+self.eye_color)
class Child(Parent):
def __init__(self, last_name, eye_color, number_of_toys):
print("Child Constructor Called")
Parent.__init__(self, last_name, eye_color)
self.number_of_toys = number_of_toys
def show_info(self):
print("Last Name - "+self.last_name)
print("Eye Color - "+self.eye_color)
print("Number of toys - "+str(self.number_of_toys))
bill = Parent("Cyrus", "brown")
bill.show_info()
jamey = Child("Cyrus", "Brown", 5)
jamey.show_info()