Beispiel #1
0
 def test_zoo_pay_worker_no_budget(self):
     z = Zoo("Zoo", 200, 2, 2)
     z.hire_worker(Vet("John", 23, 100))
     z.hire_worker(Keeper("Bill", 28, 150))
     res = z.pay_workers()
     self.assertEqual(
         res, "You have no budget to pay your workers. They are unhappy")
 def test_zoo_pay_worker_success(self):
     z = Zoo("Zoo", 1500, 2, 2)
     z.hire_worker(Vet("John", 23, 100))
     z.hire_worker(Keeper("Bill", 28, 150))
     res = z.pay_workers()
     self.assertEqual(z._Zoo__budget, 1250)
     self.assertEqual(res, "You payed your workers. They are happy. Budget left: 1250")
Beispiel #3
0
    def workers_status(self):
        keepers_count = 0
        caretakers_count = 0
        vets_count = 0

        keepers_repr = []
        caretakers_repr = []
        vets_repr = []

        for worker in self.workers:
            if worker.__class__.__name__ == "Vet":
                vets_count += 1
                vets_repr.append(Vet.__repr__(worker))

            elif worker.__class__.__name__ == "Keeper":
                keepers_count += 1
                keepers_repr.append(Keeper.__repr__(worker))

            elif worker.__class__.__name__ == "Caretaker":
                caretakers_count += 1
                caretakers_repr.append(Caretaker.__repr__(worker))

        keepers_repr = "\n".join(keepers_repr)
        caretakers_repr = "\n".join(caretakers_repr)
        vets_repr = "\n".join(vets_repr)

        return f"""You have {len(self.workers)} workers
 def test_worker_status(self):
     z = Zoo("My Zoo", 500, 3, 3)
     z.hire_worker(Vet("Leo", 35, 100))
     z.hire_worker(Keeper("Tigy", 40, 100))
     z.hire_worker(Caretaker("Chi", 24, 100))
     res = z.workers_status()
     self.assertEqual(res,
                      "You have 3 workers\n----- 1 Keepers:\nName: Tigy, Age: 40, Salary: 100\n----- 1 Caretakers:\nName: Chi, Age: 24, Salary: 100\n----- 1 Vets:\nName: Leo, Age: 35, Salary: 100")
Beispiel #5
0
 def test_keeper_repr(self):
     k = Keeper("ally", 36, 190)
     res = str(k)
     self.assertEqual(res, "Name: ally, Age: 36, Salary: 190")
Beispiel #6
0
 def test_keeper_init(self):
     k = Keeper("john", 21, 200)
     self.assertEqual(k.name, "john")
     self.assertEqual(k.age, 21)
     self.assertEqual(k.salary, 200)
Beispiel #7
0
 def test_zoo_fire_worker_success(self):
     z = Zoo("Zoo", 1500, 1, 1)
     z.hire_worker(Keeper("K", 45, 100))
     res = z.fire_worker("K")
     self.assertEqual(res, "K fired successfully")
     self.assertEqual(z.workers, [])
# 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))
Beispiel #9
0
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
print(zoo.tend_animals())

# Paying keepers
Beispiel #10
0
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
print(zoo.tend_animals())