예제 #1
0
 def test_can_instatiate_birds():
     owl = Owl("Pip", 10, 10)
     print(owl)
     meat = Meat(4)
     print(owl.make_sound())
     owl.feed(meat)
     veg = Vegetable(1)
     print(owl.feed(veg))
     print(owl)
     hen = Hen("Harry", 10, 10)
     veg = Vegetable(3)
     fruit = Fruit(5)
     meat = Meat(1)
     print(hen)
     print(hen.make_sound())
     hen.feed(veg)
     hen.feed(fruit)
     hen.feed(meat)
     print(hen)
예제 #2
0
owl = Owl("Pip", 10, 10)
print(owl)
meat = Meat(4)
print(owl.make_sound())
owl.feed(meat)
veg = Vegetable(1)
print(owl.feed(veg))
print(owl)
hen = Hen("Harry", 10, 10)
veg = Vegetable(3)
fruit = Fruit(5)
meat = Meat(1)
print(hen)
print(hen.make_sound())
hen.feed(veg)
hen.feed(fruit)
hen.feed(meat)
print(hen)


class WildFarmTests(unittest.TestCase):
    def test_first_zero(self):
        owl = Owl("Pip", 10, 10)
        self.assertEqual(str(owl), "Owl [Pip, 10, 10, 0]")
        meat = Meat(4)
        self.assertEqual(owl.make_sound(), "Hoot Hoot")
        owl.feed(meat)
        veg = Vegetable(1)
        owl.feed(veg)
        self.assertEqual(owl.feed(veg), "Owl does not eat Vegetable!")
예제 #3
0
파일: test.py 프로젝트: Vikadie/Python-OOP
from project.animals.birds import Hen, Owl
from project.animals.mammals import Mouse, Cat, Dog, Tiger
from project.food import Food, Meat, Vegetable, Fruit, Seed

owl = Mouse("Pip", 10, 10)
print(owl)
meat = Meat(4)
print(owl.make_sound())
print(owl.feed(meat))
veg = Vegetable(3)
fruit = Fruit(4)
seed = Seed(1)
print(owl.feed(veg))
print(owl.feed(seed))
print(owl.feed(fruit))
print(owl)

print("-" * 25)

hen = Hen("Harry", 10, 10)
veg = Vegetable(3)
fruit = Fruit(4)
seed = Seed(1)
meat = Meat(1)
print(hen)
print(hen.make_sound())
hen.feed(veg)
hen.feed(fruit)
hen.feed(seed)
hen.feed(meat)
print(hen)