def __init__(self): Animal.__init__(self, 'Kikakapu', ['Shrimp', 'Crab', 'Squid', 'Mussel'], ['Swamp', 'River'], 1) Swimming.__init__(self) Freshwater.__init__(self) Stagnant.__init__(self)
def __init__(self): Animal.__init__(self, "Hawaiian Happy-Face Spider", release_age=.5) Terrestrial.__init__(self) Walking.__init__(self) Stagnant.__init__(self) self.__prey = {"Crickets", "Flies"} self.leg_count = 8
def __init__(self): Animal.__init__(self, "Short Eared Owl", "Pueo") IFlying.__init__(self, True) ICan_Inhabit_Grassland.__init__(self) ICan_Inhabit_Forest.__init__(self) Identifiable.__init__(self) self.prey = ["Mouse", "Mongoose", "Rat"]
def __init__(self): pygame.init() self.window = pygame.display.set_mode( (config.screen['width'], config.screen['height'])) self.window_rect = pygame.Rect( (0, 0), (config.screen['width'], config.screen['height'])) pygame.display.set_caption("Evolution of life") self.background = pygame.image.load('images/background.jpg').convert() self.fooda = Food() self.animala = Animal() for peacock in range(config.animalsBeggining['startingPeacocksCount']): peacock = Peacock() peacock.create() self.animala.animalsList.add(peacock) self.animala.peacocksList.add(peacock) for tiger in range(config.animalsBeggining['startingTigersCount']): tiger = Tiger() tiger.create() self.animala.animalsList.add(tiger) self.animala.tigersList.add(tiger) self.tour = 0 self.food_collision_list = pygame.sprite.Group() self.peacocks_collision_list = pygame.sprite.Group() self.tigers_collision_list = pygame.sprite.Group()
def __init__(self): Animal.__init__(self, "Nene Goose") IFlying.__init__(self) IWalking.__init__(self) ITerrestrial.__init__(self) Identifiable.__init__(self) self.__prey = {"Grass", "Weedy Plants", "Berries"}
def __init__(self): Animal.__init__(self, "Fish", "Kikakapu") Identifiable.__init__(self) ISwimming.__init__(self) ICan_Inhabit_Swamp.__init__(self) IFreshwater.__init__(self) self.prey = ["Trout", "Mackarel", "Sardine"]
def __init__(self): Animal.__init__(self, "Chicken") IFlying.__init__(self) IWalking.__init__(self) ITerrestrial.__init__(self) Identifiable.__init__(self) self.__prey = {"Grass", "Corn", "Bugs"}
def __init__(self): Animal.__init__(self, "Ulae") ISaltwater.__init__(self) ISwimming.__init__(self) Identifiable.__init__(self) self.prey = ["Shrimp", "Crabs", "Squid", "Octopus"] self.min_release_age = 1
def __init__(self): Animal.__init__(self, "Ope'ape'a", release_age=5) Terrestrial.__init__(self) Flying.__init__(self) HighElevation.__init__(self) Trees.__init__(self) self.__prey = {"Leaves", "Mosquitoes", "Flies"}
def __init__(self): Animal.__init__(self, "Kikakapu", 2, 1, {"Moths", "Beetles", "Termites", "Worm"}) Forestful.__init__(self) Mountainful.__init__(self) Flying.__init__(self) Identifiable.__init__(self)
def __init__(self): Animal.__init__(self, "Kikakapau") ISwimming.__init__(self) IAquatic.__init__(self) ISaltwater.__init__(self) Identifiable.__init__(self) self.__prey = {"Trout", "Mackarel", "Salmon", "Sardine"}
def __init__(self): Animal.__init__(self, "Duck") IFlying.__init__(self) IWalking.__init__(self) ITerrestrial.__init__(self) Identifiable.__init__(self) self.__prey = { "Moss", "Bread", "Bugs" }
def __init__(self): Animal.__init__(self, "Gold Dust Day Gecko") IWalking.__init__(self) Identifiable.__init__(self) ITerrestrial.__init__(self) self.prey = ["Crickets", "Roaches", "Mealworms", "Waxworms"] self.min_release_age = 2
def __init__(self): Animal.__init__(self, "Kikakapu", 2, 1, {"Lizard Fish", "Eel", "Clams", "Trout"}) Freshwater.__init__(self) Stagnant.__init__(self) Swimming.__init__(self) Identifiable.__init__(self)
def __init__(self): Animal.__init__(self, "River dolphin") IFreshwater.__init__(self) ISwimming.__init__(self) Identifiable.__init__(self) self.prey = ["Trout", "Mackarel", "Salmon", "Sardine"] self.min_release_age = 13
def __init__(self): Animal.__init__(self, "Gold Dust Gecko", release_age=2) Terrestrial.__init__(self) Walking.__init__(self) Trees.__init__(self) self.__prey = {"Crickets", "Flies"} self.leg_count = 4
def __init__(self): Animal.__init__(self, "Pueo", release_age=8) Terrestrial.__init__(self) Flying.__init__(self) Trees.__init__(self) Grass.__init__(self) self.__prey = {"Rats", "Mice"}
def __init__(self): Animal.__init__(self, "River dolphin") IsFreshwater.__init__(self) Identifiable.__init__(self) self.__prey = { "Yellow Fin Tuna", "Mahi-Mahi", "Marlin", "Wahoo", "Ono", "Hapu'upu'u", "Kajiki", "Opakapaku", "Monchong" }
def __init__(self): Animal.__init__(self, "Pueo") IsTerrestrial.__init__(self) Identifiable.__init__(self) self.__prey = { "House Mouse", "Black Rat", "Polynesian Rat", "Mickey Mouse", "Ratatouille" }
def test_animal_walk(self): self.animal = Animal() with self.assertRaises(ValueError): self.animal.walk() self.animal.set_legs(2) self.animal.walk() self.assertEqual(self.animal.speed, .2)
def __init__(self): Animal.__init__(self, "Kikakapu") IFreshwater.__init__(self) Identifiable.__init__(self) self.__prey = { "Planktonic Animals", "Vegetation", "Trout", "Mackarel", "Salmon", "Sardine" }
def __init__(self): Animal.__init__(self, "Gold Dust Day Gecko") IWalking.__init__(self) ITerrestrial.__init__(self) IEnviroChar.__init__(self) self.__prey = {"insects"} self.hospitable_altitude.append("Low") self.hospitable_rainfall.append("Rainy") self.hospitable_sunlight.append("Shady")
def __init__(self): Animal.__init__(self, "Nene Goose") IsFlying.__init__(self) IsTerrestrial.__init__(self) Identifiable.__init__(self) self.__prey = { "Candlenut", "Pineapple", "Breadfruit", "Edible Canna", "Seagrape", "Papaya", "Coconut" }
def __init__(self, age, name): Animal.__init__(self) ISaltwater.__init__(self) ISwimming.__init__(self) self.instances.append(self) self.name = name self.species = "Ulae" self.min_release_age = 1 self.age = age self.prey = [ "trout", "mackarel", "salmon", "sardine" ]
def __init__(self): Animal.__init__(self, "Nene Goose") IFlying.__init__(self) IWalking.__init__(self) ISwimming.__init__(self) ITerrestrial.__init__(self) IEnviroChar.__init__(self) self.__prey = { "Vegetation" } self.hospitable_rainfall.append("Little") self.hospitable_sunlight.append("Full")
def __init__(self): Animal.__init__(self, "Pueo") IFlying.__init__(self) IEnviroChar.__init__(self) self.__prey = {"Rodents"} self.hospitable_altitude.append("Low") self.hospitable_rainfall.append("Rainy") self.hospitable_rainfall.append("Little") self.hospitable_sunlight.append("Shady") self.hospitable_sunlight.append("Full")
def __init__(self, age, name): Animal.__init__(self) ITerrestrial.__init__(self) IWalking.__init__(self) self.instances.append(self) self.name = name self.species = "Gold Dust Day Gecko" self.min_release_age = 2 self.age = age self.prey = ["flies", "ants"] self.tolerate_shade = True
def __init__(self): Animal.__init__(self, "Ope'ape'a") IFlying.__init__(self) ITerrestrial.__init__(self) IEnviroChar.__init__(self) self.__prey = {"Insects and Vegetation"} self.hospitable_sunlight.append("Partial") self.hospitable_sunlight.append("Shady") self.hospitable_altitude.append("Low") self.hospitable_altitude.append("High Elevation") self.hospitable_rainfall.append("Rainy")
def __init__(self, age, name): Animal.__init__(self) ITerrestrial.__init__(self) IFlying.__init__(self) self.instances.append(self) self.name = name self.species = "Pueo" self.min_release_age = 8 self.age = age self.prey = ["mouse", "rat"] self.tolerate_shade = True self.tolerate_sun = True
def __init__(self, age, name): Animal.__init__(self) ITerrestrial.__init__(self) IFlying.__init__(self) self.instances.append(self) self.name = name self.species = "Opeapea" self.min_release_age = 5 self.age = age self.prey = ["ants", "flies", "grass", "plants", "leaves"] self.high_elevation = True self.tolerate_shade = True
def setUp(self): self.conn = sqlite3.connect('animal_types.db') cursor = self.conn.cursor() create_tables(cursor) self.conn.commit() tiger_stats = cursor.execute("SELECT * FROM animal_types\ WHERE species = 'tiger'").fetchall()[0] # print(tiger_stats) # print(tiger_stats[1]) self.tiger = Animal(tiger_stats[1], 18, "Pencho", 'male', 19) lion_stats = cursor.execute("SELECT * FROM animal_types\ WHERE species = 'lion'").fetchall()[0] self.lion = Animal(lion_stats[1], 24, "Svetla", "female", 17)
def __init__(self): #constructor function Animal.__init__(self) HTML.__init__(self) self.title = "The Grey Wolf" self.animal = "GREY WOLF" self._phylum = "Chordata" self._class_ = "Mammalia" self._order = "Carnivora" self._family = "Canidae" self._genus = " Canis" self._url = "images/GreyWolf.jpg" self._avg_lifespan = "Five years " self._habitat = "Deserts, Woodlands and Arctic." self._geo_location = "North America and Europe, Australia" self.sound = "Howling" self._body_id = "wolf"
def __init__(self): #constructor function Animal.__init__(self) HTML.__init__(self) self.title = "The Rabbit" self.animal = "Belgian Hare Rabbit" self._phylum = "Chordata" self._class_ = "Mammalia" self._order = "Lagomorpha" self._family = "Leporidae" self._genus = "Sylvilagus" self._url = "images/Rabbit.jpg" self._avg_lifespan = "Ten years" self._habitat = "Woodlands, Prairies, Deserts." self._geo_location = "North, South America, Asia, Europe, Africa, Australia" self.sound = "Weening" self._body_id = "rabbit"
def __init__(self): #constructor functions Animal.__init__(self) HTML.__init__(self) self.__css_url = "" self.title = "The Fox" self.animal = "Red Fox" self._phylum = "Chordata" self._class_ = "Mammalia" self._order = "Carnivora" self.__family = "Canidae" self._genus = "Vulpes" self._url = "images/foximg.jpg" self._avg_lifespan = "Five years" self._habitat = "Woodlands" self._geo_location = "North America, Asia, Europe Australia" self.sound = "Howling" self._body_id = "fox"
def load_animal(self, animal_id): #get animal details self.cursor.execute("SELECT specie, name, age, weight, gender\ FROM animals WHERE id = ?", (animal_id,)) unparsed_animal = self.cursor.fetchone() if unparsed_animal is None: return None specie = unparsed_animal[0] name = unparsed_animal[1] age = unparsed_animal[2] weight = unparsed_animal[3] gender = unparsed_animal[4] dead_or_alive = 1 animal = Animal(specie, name, age, weight, dead_or_alive, gender) animal.gender = gender return animal
class AnimalFileAdapterTest(unittest.TestCase): """docstring for AnimalFileAdapterTest""" def setUp(self): call("py create_animals_database.py",shell=True) self.db_conn = sqlite3.connect("animals.db") self.animal = Animal(self.db_conn, "tiger", 12, "Pol", "male") self.animals_adapter = AnimalFileAdapter(self.db_conn, self.animal) def test_prepare_to_save(self): expected = ('Pol', 'tiger', 12, 'male', 144.0) self.assertEqual(expected, self.animals_adapter.prepare_to_save()) def test_save_new_animal(self): self.animals_adapter.save() self.assertEqual(1, self.animal.get_id()) def test_save_update_animal(self): self.animals_adapter.save() self.animal.age = 13 self.animals_adapter.save() sql = 'select age from zoo_animals where id=?' cursor = self.db_conn.cursor() actual = cursor.execute(sql, (self.animal.get_id(), )).fetchone()[0] self.assertEqual(13, actual) def test_load(self): self.animals_adapter.save() file_adapter = AnimalFileAdapter(self.db_conn, Animal(self.db_conn, 'lion', 1, '', '')) self.assertTrue(file_adapter.load(1)) expected = ('Pol', 'tiger', 12, 'male', 144.0) self.assertEqual(expected, file_adapter.prepare_to_save()) def tearDown(self): self.db_conn.commit() self.db_conn.close() call('rm -f animals.db', shell=True)
def test_type_food(self): self.animal = Animal(self.db_conn, 'lion', 12, 'Pol', 'female') self.assertEqual('carnivore', self.animal.type_food())
class TestAnimal(unittest.TestCase): """docstring for ZooTest""" def setUp(self): self.conn = sqlite3.connect('animal_types.db') cursor = self.conn.cursor() create_tables(cursor) self.conn.commit() tiger_stats = cursor.execute("SELECT * FROM animal_types\ WHERE species = 'tiger'").fetchall()[0] # print(tiger_stats) # print(tiger_stats[1]) self.tiger = Animal(tiger_stats[1], 18, "Pencho", 'male', 19) lion_stats = cursor.execute("SELECT * FROM animal_types\ WHERE species = 'lion'").fetchall()[0] self.lion = Animal(lion_stats[1], 24, "Svetla", "female", 17) def test_get_name(self): self.assertEqual("Pencho", self.tiger.get_name()) self.assertEqual("Svetla", self.lion.get_name()) def test_get_gender(self): self.assertEqual("female", self.lion.get_gender()) self.assertEqual("male", self.tiger.get_gender()) def test_get_weight(self): self.assertEqual(19, self.tiger.get_weight()) self.assertEqual(17, self.lion.get_weight()) def test_get_species(self): self.assertEqual("tiger", self.tiger.get_species()) self.assertEqual("lion", self.lion.get_species()) def test_get_age(self): self.assertEqual(18, self.tiger.get_age()) self.assertEqual(24, self.lion.get_age()) def test_max_weight(self): self.assertEqual(250, self.tiger.get_max_weight()) self.assertEqual(200, self.lion.get_max_weight()) def test_max_age(self): self.assertEqual(20, self.tiger.get_max_age()) self.assertEqual(15, self.lion.get_max_age()) def test_update_weight(self): self.assertEqual(31, self.tiger.update_weight(1)) self.assertEqual(24.5, self.lion.update_weight(1)) # testing weight limit self.assertEqual(250, self.tiger.update_weight(30)) self.assertEqual(200, self.lion.update_weight(100)) def test_grow(self): self.tiger.grow(12) self.assertEqual(163, self.tiger.get_weight()) self.assertEqual(19, self.tiger.get_age()) self.lion.grow(0) self.assertEqual(17, self.lion.get_weight()) self.assertEqual(24, self.lion.get_age()) # because of the chance_of_dying this test sometimes fails, as it should do # so it is commented """ def test_die(self): self.tiger.grow(180) # his new age is 198 months (max is 20 years = 240 months) self.assertEqual(False, self.tiger.die(0)) self.assertEqual(True, self.tiger.die(22)) # surely DEAD self.assertEqual(True, self.tiger.die(50)) """ def tearDown(self): conn = sqlite3.connect("animal_types.db") cursor = conn.cursor() drop_query = "DROP TABLE IF EXISTS animal_types" cursor.execute(drop_query)
def test_food_for_day(self): self.animal = Animal(self.db_conn, 'lion', 12, 'Pol', 'female') self.assertEqual(3.15, self.animal.food_for_day())
def test_get_gestation_period(self): self.animal = Animal(self.db_conn, 'lion', 12, 'Pol', 'female') self.assertEqual(3, self.animal.get_gestation_period())
def test_get_id(self): self.animal = Animal(self.db_conn, 'lion', 12, 'Pol', 'female') self.assertEqual(-1, self.animal.get_id())
def test_get_name(self): self.animal = Animal(self.db_conn, 'tiger', 12, 'Pol', 'male') self.assertEqual('Pol',self.animal.get_name())
def test_grow_young_animal(self): self.animal = Animal(self.db_conn, 'tiger', 12, 'Pol', 'male') self.animal.grow() self.assertEqual(13, self.animal.age) self.assertEqual(156, self.animal.weight)
class TestAnimal(unittest.TestCase): '''docstring for TestAnimal''' def setUp(self): call('py create_animals_database.py',shell=True) self.db_conn = sqlite3.connect('animals.db') def test_get_name(self): self.animal = Animal(self.db_conn, 'tiger', 12, 'Pol', 'male') self.assertEqual('Pol',self.animal.get_name()) def test_grow_young_animal(self): self.animal = Animal(self.db_conn, 'tiger', 12, 'Pol', 'male') self.animal.grow() self.assertEqual(13, self.animal.age) self.assertEqual(156, self.animal.weight) def test_grow_old_animal(self): self.animal = Animal(self.db_conn, 'lion', 180, 'John', 'male') self.animal.grow() self.assertEqual(200, self.animal.weight) self.assertEqual(181, self.animal.age) def test_die(self): self.animal = Animal(self.db_conn, 'raccoon', 36, 'Cohnen', 'male') self.assertEqual(True, self.animal.die()) def test_get_gestation_period(self): self.animal = Animal(self.db_conn, 'lion', 12, 'Pol', 'female') self.assertEqual(3, self.animal.get_gestation_period()) def test_get_id(self): self.animal = Animal(self.db_conn, 'lion', 12, 'Pol', 'female') self.assertEqual(-1, self.animal.get_id()) def test_food_for_day(self): self.animal = Animal(self.db_conn, 'lion', 12, 'Pol', 'female') self.assertEqual(3.15, self.animal.food_for_day()) def test_type_food(self): self.animal = Animal(self.db_conn, 'lion', 12, 'Pol', 'female') self.assertEqual('carnivore', self.animal.type_food()) def test_expenses_for_food(self): self.animal = Animal(self.db_conn, 'lion', 1, 'Pol', 'female') self.assertEqual(1.04, self.animal.expenses_for_food()) def tearDown(self): self.db_conn.commit() self.db_conn.close() call('rm -f animals.db', shell=True)
def test_die(self): self.animal = Animal(self.db_conn, 'raccoon', 36, 'Cohnen', 'male') self.assertEqual(True, self.animal.die())
def test_grow_old_animal(self): self.animal = Animal(self.db_conn, 'lion', 180, 'John', 'male') self.animal.grow() self.assertEqual(200, self.animal.weight) self.assertEqual(181, self.animal.age)
def test_expenses_for_food(self): self.animal = Animal(self.db_conn, 'lion', 1, 'Pol', 'female') self.assertEqual(1.04, self.animal.expenses_for_food())
def setUp(self): call("py create_animals_database.py",shell=True) self.db_conn = sqlite3.connect("animals.db") self.animal = Animal(self.db_conn, "tiger", 12, "Pol", "male") self.animals_adapter = AnimalFileAdapter(self.db_conn, self.animal)