Skip to content

Commit 978812d

Browse files
committed
Exercise 12 completed
1 parent 6325890 commit 978812d

1 file changed

Lines changed: 45 additions & 1 deletion

File tree

‎Sprint 5 Prep Exercises/exercise_12.py‎

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,59 @@ def get_full_name(self) -> str:
2323
return f"{self.first_name} {self.last_name}{suffix}"
2424

2525
person1 = Child("Elizaveta", "Alekseeva")
26+
# Prediction: Creates instance of Child class with first name "Elizaveta" and last name "Alekseeva".
27+
print(person1)
28+
print(person1.first_name)
29+
print(person1.last_name)
30+
# Outcome: As expected.
31+
32+
2633
print(person1.get_name())
34+
# Prediction: Child inherits Parent methods, therefore calls get_name method: "Elizaveta Alekseeva"
35+
# Outcome: As expected.
36+
2737
print(person1.get_full_name())
38+
# Prediction: Calls get_full_name on child, no previous names: "Elizaveta Alekseeva"
39+
# Outcome: As expected.
40+
2841
person1.change_last_name("Tyurina")
42+
# Prediction: Changes last_name to "Tyurina", and previous_last_names to ["Alekseeva"], returns nothing
43+
print(person1.last_name)
44+
print(person1.previous_last_names)
45+
# Outcome: As expected.
46+
2947
print(person1.get_name())
48+
# Prediction: Child inherits Parent methods, therefore calls get_name method: "Elizaveta Alekseeva"
49+
# Outcome: As expected.
50+
3051
print(person1.get_full_name())
52+
# Prediction: Returns first_name last_name (née previous_last_names[0]) (original last name)
53+
# ""Elizaveta Tyurina (née Alekseeva)"
54+
# Outcome: As expected.
3155

3256
person2 = Parent("Elizaveta", "Alekseeva")
57+
# Prediction: Creates instance of Parent class with first name "Elizaveta" and last name "Alekseeva".
58+
print(person2)
59+
print(person2.first_name)
60+
print(person2.last_name)
61+
# Outcome: As expected.
62+
3363
print(person2.get_name())
64+
# Prediction: Calls get_name method: "Elizaveta Alekseeva"
65+
# Outcome: As expected.
66+
3467
# print(person2.get_full_name())
68+
# Prediction: Parent instance has not access to Child methods, will error that there is no method of get_full_name.
69+
# Outcome: AttributeError: 'Parent' object has no attribute 'get_full_name'
70+
3571
# person2.change_last_name("Tyurina")
72+
# Prediction: Parent instance has not access to Child methods, will error that there is no method of change_last_name.
73+
# Outcome: AttributeError: 'Parent' object has no attribute 'change_last_name'
74+
3675
print(person2.get_name())
37-
# print(person2.get_full_name())
76+
# Prediction: Calls get_name method: "Elizaveta Alekseeva" as name has not changed due to inability to call change_last_name
77+
# Outcome: As expected.
78+
79+
# print(person2.get_full_name())
80+
# Prediction: Parent instance has not access to Child methods, will error that there is no method of get_full_name.
81+
# Outcome: AttributeError: 'Parent' object has no attribute 'get_full_name'

0 commit comments

Comments
 (0)