Exemplo n.º 1
0
 def test_zoo_tend_animal_success(self):
     z = Zoo("Zoo", 500, 2, 2)
     z.add_animal(Lion("John", "m", 2), 100)
     z.add_animal(Tiger("Bill", "f", 4), 100)
     res = z.tend_animals()
     self.assertEqual(z._Zoo__budget, 205)
     self.assertEqual(res, "You tended all the animals. They are happy. Budget left: 205")
Exemplo n.º 2
0
 def test_zoo_tend_animal_no_budget(self):
     z = Zoo("Zoo", 250, 2, 2)
     z.add_animal(Lion("John", "m", 2), 100)
     z.add_animal(Tiger("Bill", "f", 4), 100)
     res = z.tend_animals()
     self.assertEqual(
         res, "You have no budget to tend the animals. They are unhappy.")
Exemplo n.º 3
0
    def animals_status(self):
        lions_count = 0
        tigers_count = 0
        cheetahs_count = 0

        lions_repr = []
        tigers_repr = []
        cheetahs_repr = []

        for animal in self.animals:
            if animal.__class__.__name__ == "Tiger":
                tigers_count += 1
                tigers_repr.append(Tiger.__repr__(animal))

            elif animal.__class__.__name__ == "Lion":
                lions_count += 1
                lions_repr.append(Lion.__repr__(animal))

            elif animal.__class__.__name__ == "Cheetah":
                cheetahs_count += 1
                cheetahs_repr.append(Cheetah.__repr__(animal))

        lions_repr = "\n".join(lions_repr)
        tigers_repr = "\n".join(tigers_repr)
        cheetahs_repr = "\n".join(cheetahs_repr)

        return f"""You have {len(self.animals)} animals
Exemplo n.º 4
0
 def test_animal_status(self):
     z = Zoo("My Zoo", 500, 3, 3)
     z.add_animal(Lion("Leo", "Male", 3), 100)
     z.add_animal(Tiger("Tigy", "Female", 4), 100)
     z.add_animal(Cheetah("Chi", "Female", 2), 100)
     res = z.animals_status()
     self.assertEqual(res,
                      "You have 3 animals\n----- 1 Lions:\nName: Leo, Age: 3, Gender: Male\n----- 1 Tigers:\nName: Tigy, Age: 4, Gender: Female\n----- 1 Cheetahs:\nName: Chi, Age: 2, Gender: Female")
Exemplo n.º 5
0
 def test(self):
     z = Zoo("My Zoo", 1500, 6, 10)
     res = z.add_animal(Lion("Neo", "Male", 2), 1000)
     self.assertEqual(res, "Neo the Lion added to the zoo")
     self.assertEqual(len(z.animals), 1)
     self.assertEqual(z._Zoo__budget, 500)
Exemplo n.º 6
0
 def test_lion_repr(self):
     l = Lion("b", "f", 2)
     res = str(l)
     self.assertEqual(res, "Name: b, Age: 2, Gender: f")
Exemplo n.º 7
0
 def test_lion_get_needs(self):
     l = Lion("b", "f", 2)
     res = l.get_needs()
     self.assertEqual(res, 50)
Exemplo n.º 8
0
 def test_lion_init(self):
     l = Lion("a", "m", 4)
     self.assertEqual(l.name, "a")
     self.assertEqual(l.gender, "m")
     self.assertEqual(l.age, 4)
Exemplo n.º 9
0
 def test_zoo_add_animal_no_space(self):
     z = Zoo("My Zoo", 1500, 0, 10)
     res = z.add_animal(Lion("Neo", "Male", 2), 1000)
     self.assertEqual(res, "Not enough space for animal")
     self.assertEqual(len(z.animals), 0)
     self.assertEqual(z._Zoo__budget, 1500)
Exemplo n.º 10
0
 def test_zoo_add_animal_no_budget(self):
     z = Zoo("My Zoo", 500, 6, 10)
     res = z.add_animal(Lion("Neo", "Male", 2), 1000)
     self.assertEqual(res, "Not enough budget")
     self.assertEqual(len(z.animals), 0)
     self.assertEqual(z._Zoo__budget, 500)
Exemplo n.º 11
0
from project.caretaker import Caretaker
from project.cheetah import Cheetah
from project.keeper import Keeper
from project.lion import Lion
from project.tiger import Tiger
from project.vet import Vet
from project.zoo import Zoo

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),
Exemplo n.º 12
0
from project.caretaker import Caretaker
from project.cheetah import Cheetah
from project.keeper import Keeper
from project.lion import Lion
from project.tiger import Tiger
from project.vet import Vet
from project.zoo import Zoo


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
Exemplo n.º 13
0
 def test_lion_get_needs(self):
     l = Lion("b", "f", 2)
     res = l.money_for_care
     self.assertEqual(res, 50)