-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanimals.py
More file actions
89 lines (75 loc) · 1.87 KB
/
animals.py
File metadata and controls
89 lines (75 loc) · 1.87 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import pandas as pd
class duck:
"""it's a duck! it's able to do the following:
+ eat - eats food cuz it's hungry
+ crap - it's a bodily function
+ die - that's what happens
"""
animal = 'bird'
def __init__(self, name):
self.name = name
self.status = 'Alive!'
self.tummy = 'empty'
self.wings = 'furry'
def eat(self, food):
if isinstance(food, str):
print(food, 'tastes so good!')
self.tummy = 'full of ' + food
else:
print('thats not food!')
def crap(self, x):
self.size = x * 2
print('all good now')
print('this big', str(self.size))
self.tummy = 'empty'
def die(self):
if self.status == 'dead :(':
print('what is dead may never die')
return
print('RIP mofo')
print(str(self.size))
self.status = 'dead :('
class chicken:
"""it's a chcken
"""
animal = 'bird'
def __init__(self, name):
self.name = name
self.fly = False
class cow:
"""it's a cow
"""
animal = 'bovine'
def __init__(self, name):
self.name = name
def moo(self, x):
self.size = x * 2
print('mooooooo')
print('mooooooooooooo', str(self.size))
self.tummy = 'empty'
class dog:
"""it's a dog
"""
animal = 'canine'
def __init__(self, name):
self.name = name
self.bark = 'loud'
self.react = 'weak'
class cat:
"""it's a cat
"""
animal = 'feline'
def __init__(self, name):
self.name = name
self.bark = None
def meow(self, volume):
self.volume = volume
print('nice meow')
def kill(o):
"""to kill an animal - it's able to kill the following classes:
+ duck
"""
if isinstance(o, duck):
o.die()
else:
print("can't kill it.")