Exemplo n.º 1
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.º 2
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.º 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_tiger_repr(self):
     t = Tiger("w", "f", 3)
     res = str(t)
     self.assertEqual(res, "Name: w, Age: 3, Gender: f")
Exemplo n.º 6
0
 def test_tiger_get_needs(self):
     t = Tiger("v", "f", 7)
     res = t.get_needs()
     self.assertEqual(res, 45)
Exemplo n.º 7
0
 def test_tiger_init(self):
     t = Tiger("z", "m", 1)
     self.assertEqual(t.name, "z")
     self.assertEqual(t.gender, "m")
     self.assertEqual(t.age, 1)
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.º 9
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.º 10
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:
Exemplo n.º 11
0
 def test_tiger_get_needs(self):
     t = Tiger("v", "f", 7)
     res = t.money_for_care
     self.assertEqual(res, 45)