-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCat.py
44 lines (36 loc) · 935 Bytes
/
Cat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
class Cat:
# Attributes
mood = 0
hungry = 0
energy = 0
# Methods
def __init__(self, mood=mood, hungry=hungry, energy=energy):
self.mood = mood
self.hungry = hungry
self.energy = energy
def meow(self):
print("meow!")
def sleep(self):
self.energy += 1
self.hungry += 1
self.display()
def play(self):
self.mood += 1
self.energy -= 1
self.meow()
self.display()
def feed(self):
self.hungry -= 1
self.mood += 1
self.meow()
self.display()
def display(self):
print("Mood: ", self.mood)
print("Energy: ", self.energy)
print("Hungry: ", self.hungry)
print() # enter new space
if __name__ == "__main__":
Garfield = Cat()
Garfield.sleep()
Garfield.feed()
Garfield.play()