Skip to content

Commit 80ab3d6

Browse files
committed
method overridding
1 parent d79c98a commit 80ab3d6

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

inheritance_in_python/inheritance.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@ def __init__(self, last_name, eye_color, num_of_toys):
1515
Parent.__init__(self, last_name, eye_color)
1616
self.number_of_toys = num_of_toys
1717

18+
def show_info(self):
19+
print("Last Name -" + self.last_name)
20+
print("Eye Color -" + self.eye_color)
21+
print("Number of toys -" + str(self.number_of_toys))
22+
1823

19-
billy_cyrus = Parent("Cyrus", "blue")
24+
# billy_cyrus = Parent("Cyrus", "blue")
2025
# print(billy_cyrus.last_name)
21-
billy_cyrus.show_info()
26+
# billy_cyrus.show_info()
2227

23-
# miley_cyrus = Child("Cyrus", "Blue", 5)
28+
miley_cyrus = Child("Cyrus", "Blue", 5)
29+
miley_cyrus.show_info()
2430
# print(miley_cyrus.last_name)
2531
# print(miley_cyrus.number_of_toys)

0 commit comments

Comments
 (0)