-
Notifications
You must be signed in to change notification settings - Fork 0
/
requirement.txt
183 lines (173 loc) · 8.73 KB
/
requirement.txt
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
1. Wild Cat Zoo
In this exercise we are going to create a whole project called "Wild Cat Zoo". We are going to create the project step-by-step starting with the project structure:
Please create separate file for each class as shown above and submit a zip file containing all files (zip the whole project folder/module) - it is important to include all files in project module in order to be able to make proper imports.
Class Lion
Attributes
Public attribute name: string
Public attribute gender: string
Public attribute age: number
Methods
__init__(name, gender, age) - set all the attributes to the given ones
get_needs() - returns the number 50 (amount of money needed to tend the animal)
__repr__() - returns string representation of the lion in the format: "Name: {name}, Age: {age}, Gender: {gender}"
Class Tiger
Attributes
Public attribute name: string
Public attribute gender: string
Public attribute age: number
Methods
__init__(name, gender, age) - set all the attributes to the given ones
get_needs() - returns the number 45 (amount of money needed to tend the animal)
__repr__() - returns string representation of the tiger in the format: "Name: {name}, Age: {age}, Gender: {gender}"
Class Cheetah
Attributes
Public attribute name: string
Public attribute gender: string
Public attribute age: number
Methods
__init__(name, gender, age) - set all the attributes to the given ones
get_needs() - returns the number 60 (amount of money needed to tend the animal)
__repr__() - returns string representation of the cheetah in the format: "Name: {name}, Age: {age}, Gender: {gender}"
Class Keeper
Attributes
Public attribute name: string
Public attribute age: number
Public attribute salary: number
Methods
__init__(name, age, salary) - set all the attributes to the given ones
__repr__() - returns string representation of the keeper in the format: "Name: {name}, Age: {age}, Salary: {salary}"
Class Caretaker
Attributes
Public attribute name: string
Public attribute age: number
Public attribute salary: number
Methods
__init__(name, age, salary) - set all the attributes to the given ones
__repr__() - returns string representation of the caretaker in the format: "Name: {name}, Age: {age}, Salary: {salary}"
Class Vet
Attributes
Public attribute name: string
Public attribute age: number
Public attribute salary: number
Methods
__init__(name, age, salary) - set all the attributes to the given ones
__repr__() - returns string representation of the vet in the format: "Name: {name}, Age: {age}, Salary: {salary}"
Class Zoo
Attributes
Private attribute animal_capacity: number
Private attribute workers_capacity: number
Private attribute budget: number
Public attribute name: string
Public attribute animals: list (empty upon initialization)
Public attribute workers: list (empty upon initialization)
Methods
__init__(name, budget, animlal_capacity, workers_capacity) - set the attributes to the given ones
add_animal(animal, price)
• If you have enough budget and capacity add the animal (instance of Lion/Tiger/Cheetah) to the animals list, reduce the budget and return "{name} the {type of animal (Lion/Tiger/Cheetah)} added to the zoo"
• If you have capacity, but no budget, return "Not enough budget"
• In any other case, you don't have space and you should return "Not enough space for animal"
hire_worker(worker)
• If you have enough space for the worker (instance of Keeper/Caretaker/Vet), add him to the workers and return "{name} the {type(Keeper/Vet/Caretaker)} hired successfully"
• Otherwise return "Not enough space for worker"
fire_worker(worker_name)
• If there is a worker with that name in the workers list, remove him and return "{worker_name} fired successfully"
• Otherwise return "There is no {worker_name} in the zoo"
pay_workers()
• If you have enough budget to pay the workers (sum their salaries) pay them and return "You payed your workers. They are happy. Budget left: {left_budget}"
• Otherwise return "You have no budget to pay your workers. They are unhappy"
tend_animals()
• If you have enough budget to tend the animals reduce the budget and return "You tended all the animals. They are happy. Budget left: {left_budget}"
• Otherwise return "You have no budget to tend the animals. They are unhappy."
profit(amount)
• Increase the budget with the given amount of profit
animals_status()
• Returns the following string:
You have {total_animals_count} animals
----- {amount_of_lions} Lions:
{lion1}
…
----- {amount_of_tigers} Tigers:
{tiger1}
…
----- {amount_of_cheetahs} Cheetahs:
{cheetah1}
…
• Hint: use the __repr__ methods of the animals to print them on the console
workers_status()
• Returns the following string:
You have {total_workers_count} workers
----- {amount_of_keepers} Keepers:
{keeper1}
…
----- {amount_of_caretakers} Caretakers:
{caretaker1}
…
----- {amount_of_vetes} Vets:
{vet1}
…
• Hint: use the __repr__ methods of the workers to print them on the console
Examples
Test Code:
zoo = Zoo("Zootopia", 3000, 5, 8)
# Animals creation
animals = [Cheetah("Cheeto", "Male", 2), Cheetah("Cheetia", "Female", 1), Lion("Simba", "Male", 4), Tiger("Zuba", "Male", 3), Tiger("Tigeria", "Female", 1), Lion("Nala", "Female", 4)]
# Animal prices
prices = [200, 190, 204, 156, 211, 140]
# Workers creation
workers = [Keeper("John", 26, 100), Keeper("Adam", 29, 80), Keeper("Anna", 31, 95), Caretaker("Bill", 21, 68), Caretaker("Marie", 32, 105), Caretaker("Stacy", 35, 140), Vet("Peter", 40, 300), Vet("Kasey", 37, 280), Vet("Sam", 29, 220)]
# Adding all animals
for i in range(len(animals)):
animal = animals[i]
price = prices[i]
print(zoo.add_animal(animal, price))
# Adding all workers
for worker in workers:
print(zoo.hire_worker(worker))
# Tending animals
print(zoo.tend_animals())
# Paying keepers
print(zoo.pay_workers())
# Fireing worker
print(zoo.fire_worker("Adam"))
# Printing statuses
print(zoo.animals_status())
print(zoo.workers_status())
Output:
Cheeto the Cheetah added to the zoo
Cheetia the Cheetah added to the zoo
Simba the Lion added to the zoo
Zuba the Tiger added to the zoo
Tigeria the Tiger added to the zoo
Not enough space for animal
John the Keeper hired successfully
Adam the Keeper hired successfully
Anna the Keeper hired successfully
Bill the Caretaker hired successfully
Marie the Caretaker hired successfully
Stacy the Caretaker hired successfully
Peter the Vet hired successfully
Kasey the Vet hired successfully
Not enough space for worker
You tended all the animals. They are happy. Budget left: 1779
You payed your workers. They are happy. Budget left: 611
Adam fired successfully
You have 5 animals
----- 1 Lions:
Name: Simba, Age: 4, Gender: Male
----- 2 Tigers:
Name: Zuba, Age: 3, Gender: Male
Name: Tigeria, Age: 1, Gender: Female
----- 2 Cheetahs:
Name: Cheeto, Age: 2, Gender: Male
Name: Cheetia, Age: 1, Gender: Female
You have 7 workers
----- 2 Keepers:
Name: John, Age: 26, Salary: 100
Name: Anna, Age: 31, Salary: 95
----- 3 Caretakers:
Name: Bill, Age: 21, Salary: 68
Name: Marie, Age: 32, Salary: 105
Name: Stacy, Age: 35, Salary: 140
----- 2 Vets:
Name: Peter, Age: 40, Salary: 300
Name: Kasey, Age: 37, Salary: 280