Пример #1
0
class FishTest(unittest.TestCase):
    def setUp(self):
        self.age = 2
        self.ageNotIncr = 4

        self.fish = Fish(self.age, "M")

    def tearDown(self):
        pass

    def testGetAge(self):
        self.assertEqual(self.fish.getAge(), self.age)

    def testIncrAge(self):
        self.assertTrue(self.fish.incrAge())

    def testRepr(self):
        self.assertEqual(repr(self.fish), "FM2")

    def testNotIncrAge(self):
        self.fish.age = self.ageNotIncr
        self.assertFalse(self.fish.incrAge())

    def testRandomCreationAge(self):
        fish = Fish()
        self.assertIn(fish.getAge(), range(5))

    def testRandomCreationGender(self):
        fish = Fish()
        self.assertIn(fish.gender, ["M", "F"])
Пример #2
0
 def create_assets(self):
     bears = [Bear('bear') for i in range(self.bears)]
     fish = [Fish('fish') for j in range(self.fish)]
     animals = bears + fish
     ecosystem = River(animals, self.river)
     cycles = self.cycles
     return animals, ecosystem, cycles
Пример #3
0
 def test_shark_move(self):
     s_test = Fish([1, 1])
     # surrounding = [[0,1], [1,0],[-1, 0], [0,-1]]
     self.assertEqual(s_test.move([[0, 1], [1, 0], [-1, 0]]), [1, 0])
     self.assertEqual(s_test.move([[0, 1], [1, 0], [-1, 0], [0, -1]]), None)
     for _ in range(100):
         self.assertIn(s_test.move([[-1, 0], [0, -1]]), [[1, 2], [2, 1]])
         self.assertIn(s_test.move([[-1, 0]]), [[1, 0], [2, 1], [1, 2]])
         self.assertIn(s_test.move([]), [[1, 0], [0, 1], [1, 2], [2, 1]])
Пример #4
0
 def generate(size, bears_num, fish_num):
     """
     Generates an starting ma
     """
     lst = [None] * size
     indexes = random.sample(range(size), bears_num + fish_num)
     for i in indexes[:bears_num]:
         lst[i] = Fish()
     for i in indexes[bears_num:]:
         lst[i] = Bear()
     return lst
Пример #5
0
 def create_assets(self):
     """Creates animals and river"""
     bears = [
         Bear('bear', rnd.choice([True, False]), rnd.random())
         for i in range(self.bears)
     ]
     fish = [
         Fish('fish', rnd.choice([True, False]), rnd.random())
         for j in range(self.fish)
     ]
     animals = bears + fish
     ecosystem = River(animals, self.river)
     cycles = self.cycles
     return animals, ecosystem, cycles
Пример #6
0
 def testRandomCreationGender(self):
     fish = Fish()
     self.assertIn(fish.gender, ["M", "F"])
Пример #7
0
 def testRandomCreationAge(self):
     fish = Fish()
     self.assertIn(fish.getAge(), range(5))
Пример #8
0
    def setUp(self):
        self.age = 2
        self.ageNotIncr = 4

        self.fish = Fish(self.age, "M")
Пример #9
0
from animals import Parakeet, Earth_Worm, Terrapin, Snake, Mouse, Ant, Finch, Fish, Copperhead, Gerbil
from habitats import Aquarium, Bird_House, Dirt_Pile, Yard

parakeet = Parakeet('parry')
worm = Earth_Worm('wormy')
turtle = Terrapin('terry')
snake = Snake('snake')
mouse = Mouse('mickey')
ant = Ant('Anty')
finch = Finch('finchy')
betta = Fish('fishy')
Copperhead = Copperhead('coppy')
gerbil = Gerbil("gerry")

aquarium = Aquarium("aquarium")
bird_house = Bird_House("birdville")
dirty = Dirt_Pile('dirty')
yard = Yard('yard')

aquarium.add_animal(betta)

print(aquarium)
Пример #10
0
#walking🦙
june = Llama("June","Llama", "morning","Macaroons",123456789)
johnny = Capybara("Johnny","Capybara", "midday", "pumpkins", 111111)
raphael = Tortoise("Raphael","Tortoise", "afternoon", "pizza", 222222)
wilbur = Pig("Wilbur","Pig", "morning", "slop", 333333)
ernesto = Ermine("Ernesto","Ermine", "afternoon","popsicles", 444444)

#slithering🐍
sam = Garden_Snake("Sam", "Garden Snake", "tomatoes", "bugs", 987)  
errol = Earthworm("Errol", "Earthworm", "fertilizer", "dirt", 654)  
sal = Salamander("Sal", "Salamander", "flies", "bugs", 321)  
pippin = Python_Snake("Pippin", "Python Snake", "mouse","mice", 000)  
bruce = Boa_Snake("Bruce", "Boa Snake", "mouse", "rats", 54654)   

#swimming🐠
nemo = Fish("Nemo", "Fish", "morning", "plankton", 101010)
alan = Alligator("Alan", "Alligator","afternoon", "steak", 788789)
cedric = Seahorse("Cedric", "Seahorse", "afternoon", "plankton", 555666)
fred = Frog("Fred", "Frog", "morning", "flies", 789321)
pedro = Platypus("Pedro", "Platypus", "morning", "gummie bears", 5556666555)

varmint_village = PettingZoo("Varmint Village", "cute and fuzzy critters to cuddle")
slither_inn = SnakePit("Slither Inn", "sleek and slithering creatures all around you")
critter_cove = Wetlands("Critter Cove", "If it swims and can be caught, it's in here")

varmint_village.add_animal(june)
varmint_village.add_animal(johnny)
varmint_village.add_animal(alan)

slither_inn.add_animal(sam)
slither_inn.add_animal(errol)
fluffy = Alpaca("Fluffy", "Domestic Alpaca", "morning", "Alpaca Chow", 12348)

porky = Pig("Porky", "Pot Belly Pig", "midday", "Pig Chow", 12349)

bertha = Snake("Bertha", "Green Anaconda", "Snake Chow", 23456)

jose = Lizard("Jose", "Mexican Beaded Lizard", "afternoon", "Lizard Chow", 23457)

wayne = Tortoise("Wayne", "Galapagos Tortoise", "morning", "Tortoise Chow", 23458)

michelangelo = Turtle("Michelangelo", "Teenage Mutant Ninja Turtle", "midday", "Turtle Chow", 23459)

chompy = Alligator("Chompy", "American Alligator", "afternoon", "Alligator Chow", 34567)

nemo = Fish("Nemo", "Clown Fish", "Fish Chow", 34568)

miss_blue = Bird("Miss Blue", "Great Blue Turaco", "morning", "Bird Chow", 34569)

frogger = Frog("Frogger", "Green Frog", "midday", "Frog Chow", 45678)

mr_toad = Toad("Mr. Toad", "Common Toad", "afternoon", "Toad Chow", 45679)

donald = Duck("Donald", "American Pekin Duck", "morning", "Duck Chow", 56789)

# Create a Goose
bob = Goose("Bob", "Canada goose", "watercress sandwiches", 12341)
bob.run()
bob.swim()

# Create an attraction
Пример #12
0
from animals import Lizard, Donkey, Llama, Frog, Goat, Snake, Duck, Fish, Bull, Pigeon, Stork, Rabbit, Snail, Parakeet, Rhino
from attractions import PettingZoo, SnakePit, Wetlands

kenny = Lizard('Kenny', 'lizard', 'manflesh', 69420)
jenny = Donkey('Jenny', 'donkey', 'midnight', 'manflesh', 1337)
penny = Llama('Penny', 'llama', 'dusk', 'manflesh', 808)
benny = Frog('Benny', 'frog', 'manflesh', 8675309)
lenny = Goat('Lenny', 'goat', 'dusk', 'manflesh', 123)
vinny = Snake('Vinny', 'snake', 'mouseflesh', 324)
connie = Duck('Connie', 'duck', 'dawn', 'gooseflesh', 909)
johnny = Fish('Johnny', 'fish', 'fishflesh', 9)
ronnie = Bull('Ronnie', 'bull', 'midnight', 'manflesh', 1011)
lonny = Pigeon('Lonny', 'pigeon', 'anything', 666)
yonni = Stork('Yonni', 'stork', 'fishflesh', 2244)
donnie = Rabbit('Donnie', 'rabbit', 'dusk', 'carrotflesh', 42)
bonnie = Snail('Bonnie', 'snail', 'unknown', 1307)
keeter = Parakeet('Keeter', 'parakeet', 'snailflesh', 789)
reeter = Rhino('Reeter', 'rhino', 'dusk', 'manflesh', 2)

eatin_good = PettingZoo('Eatin Good')
baller_crawler = SnakePit('Baller Crawler')
wetty_already = Wetlands('Wetty Already')

eatin_good.addAnimals(jenny, penny, lenny, ronnie, donnie, reeter)
baller_crawler.addAnimals(kenny, benny, vinny, bonnie)
wetty_already.addAnimals(connie, johnny, lonny, yonni, keeter)

for animal in eatin_good.animals:
    print(
        f"{animal.name} is a good {animal.species} in {eatin_good.attraction_name}"
    )