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 ad6e3df

Browse files
Update main.py
1 parent 562a524 commit ad6e3df

File tree

1 file changed

+26
-38
lines changed

1 file changed

+26
-38
lines changed

‎main.py‎

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,31 @@
1-
class Car:
2-
name = None
3-
class motorCycle:
4-
name = None
5-
def changeColor(Car, name):
6-
car.name = name
7-
def changeColor(motorCycle, name):
8-
motorCycle.name = name
1+
class Duck:
2+
def walk(self):
3+
print("Duck is walking")
4+
def talk(self):
5+
print("Duck is quackng")
6+
class Person:
7+
def catch(self, Duck):
8+
Duck.walk()
9+
Duck.talk()
10+
print("You catch me")
11+
class Chicken:
12+
def walk(self):
13+
print("The chicken is walking")
14+
def talk(self):
15+
print("The chicken is talking")
916

10-
car_1 = Car()
11-
car_2 = Car()
12-
car_3 = Car()
13-
changeColor(car_1, "Lamborghini")
14-
changeColor(car_2, "Ferrari")
15-
changeColor(car_3, "McLaren")
16-
17-
bike_1 = motorCycle()
18-
bike_2 = motorCycle()
19-
bike_3 = motorCycle()
20-
changeColor(bike_1, "Duccati")
21-
changeColor(bike_2, "Hayabusa")
22-
changeColor(bike_3, "Himalayan Bullet")
23-
24-
print("Car Details: ")
25-
print(car_1.name)
26-
print(car_2.name)
27-
print(car_3.name)
28-
print("Bike Details: ")
29-
print(bike_1.name)
30-
print(bike_2.name)
31-
print(bike_3.name)
17+
duck = Duck()
18+
chicken = Chicken()
19+
person = Person()
20+
person.catch(duck)
21+
person.catch(chicken)
3222

3323
"""
3424
Output:
35-
Car Details:
36-
Lamborghini
37-
Ferrari
38-
McLaren
39-
Bike Details:
40-
Duccati
41-
Hayabusa
42-
Himalayan Bullet
25+
Duck is walking
26+
Duck is quackng
27+
You catch me
28+
The chicken is walking
29+
The chicken is talking
30+
You catch me
4331
"""

0 commit comments

Comments
(0)

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