Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 94d21cc

Browse files
Add files via upload
1 parent 48eda6b commit 94d21cc

File tree

1 file changed

+89
-37
lines changed

1 file changed

+89
-37
lines changed

‎Section_05/assignment_01.py

Lines changed: 89 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,60 +12,112 @@
1212
dog, fish and bird and make them eat and move.
1313
1414
"""
15+
# Your Code Below:
1516

16-
class Animal:
17-
def __init__(self):
18-
print("Animal Constructed")
1917

20-
def move(self):
21-
print("Animal Moving...")
2218

23-
def eat(self):
24-
print("Animal Eating...")
2519

2620

2721

28-
class Bird(Animal):
2922

30-
def __init__(self, bird_age, bird_name):
31-
Animal.__init__(self)
32-
self.age = bird_age
33-
self.name = bird_name
3423

35-
def move(self):
36-
print("Bird flying...")
3724

3825

3926

40-
class Fish(Animal):
4127

42-
def __init__(self, bird_age, bird_name):
43-
Animal.__init__(self)
44-
self.age = bird_age
45-
self.name = bird_name
4628

47-
def move(self):
48-
print("Fish Swimming...")
4929

5030

51-
class Dog(Animal):
5231

53-
def __init__(self, bird_age, bird_name):
54-
Animal.__init__(self)
55-
self.age = bird_age
56-
self.name = bird_name
5732

58-
def move(self):
59-
print("Dog Running ...")
6033

61-
mydog = Dog(3, "wolfy")
62-
mydog.move()
63-
mydog.eat()
6434

65-
mydog = Fish(1, "nemo")
66-
mydog.move()
67-
mydog.eat()
6835

69-
mydog = Bird(3, "jojo")
70-
mydog.move()
71-
mydog.eat()
36+
37+
38+
39+
40+
41+
42+
43+
44+
45+
46+
47+
48+
49+
50+
51+
52+
53+
54+
55+
56+
57+
58+
59+
60+
61+
62+
63+
64+
65+
66+
67+
# Solution:
68+
# class Animal:
69+
# def __init__(self):
70+
# print("Animal Constructed")
71+
#
72+
# def move(self):
73+
# print("Animal Moving...")
74+
#
75+
# def eat(self):
76+
# print("Animal Eating...")
77+
#
78+
#
79+
#
80+
# class Bird(Animal):
81+
#
82+
# def __init__(self, bird_age, bird_name):
83+
# Animal.__init__(self)
84+
# self.age = bird_age
85+
# self.name = bird_name
86+
#
87+
# def move(self):
88+
# print("Bird flying...")
89+
#
90+
#
91+
#
92+
# class Fish(Animal):
93+
#
94+
# def __init__(self, bird_age, bird_name):
95+
# Animal.__init__(self)
96+
# self.age = bird_age
97+
# self.name = bird_name
98+
#
99+
# def move(self):
100+
# print("Fish Swimming...")
101+
#
102+
#
103+
# class Dog(Animal):
104+
#
105+
# def __init__(self, bird_age, bird_name):
106+
# Animal.__init__(self)
107+
# self.age = bird_age
108+
# self.name = bird_name
109+
#
110+
# def move(self):
111+
# print("Dog Running ...")
112+
#
113+
# mydog = Dog(3, "wolfy")
114+
# mydog.move()
115+
# mydog.eat()
116+
#
117+
# mydog = Fish(1, "nemo")
118+
# mydog.move()
119+
# mydog.eat()
120+
#
121+
# mydog = Bird(3, "jojo")
122+
# mydog.move()
123+
# mydog.eat()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /