Exemple #1
0
 def test_new_predator_eats_prey(self):
     dolly = Sheep("Dolly")
     freddie = Lion("Freddie")
     cage = Cage()
     cage.add_animal(dolly)
     cage.add_animal(freddie)
     self.assertEqual(cage.animals, [freddie])
Exemple #2
0
 def test_predator_eats_new_prey(self):
     freddie = Lion("Freddie")
     leonardo = Turtle("Leonardo")
     cage = Cage()
     cage.add_animal(freddie)
     cage.add_animal(leonardo)
     self.assertEqual(cage.animals, [freddie, leonardo])
Exemple #3
0
 def test_delete_animal_from_cage(self):
     freddie = Lion("Freddie")
     leonardo = Turtle("Leonardo")
     cage = Cage()
     cage.add_animal(freddie)
     cage.add_animal(leonardo)
     cage.delete_animal(freddie)
     self.assertEqual(cage.animals, [leonardo])
Exemple #4
0
 def test_add_animal_to_cage(self):
     freddie = Lion("Freddie")
     cage = Cage()
     cage.add_animal(freddie)
     self.assertEqual(cage.animals, [freddie])
Exemple #5
0
It shows how zoos, cages and animals can be created, cages can be added to the zoo and animals can be
added to the cages
"""
from zoo_project import Cage, Animal, Zoo

zoo = Zoo("London Zoo")

cage1 = Cage()
cage2 = Cage()

zoo.add_cage(cage1)
zoo.add_cage(cage2)

print(zoo.count_cages())
print(zoo.cages)

freddie_the_lion = Animal("Freddie", "Lion")
bobby_the_sheep = Animal("Bobby", "Sheep")
turty_the_turtle = Animal("Turty", "Turtle")
flying_the_tiger = Animal("Flying", "Tiger")
linus_the_penguin = Animal("Linus", "Penguin")

cage1.add_animal(freddie_the_lion)
cage1.add_animal(bobby_the_sheep)
cage1.add_animal(turty_the_turtle)
cage2.add_animal(flying_the_tiger)
cage2.add_animal(linus_the_penguin)

print(cage1.animals)
print(cage2.animals)