Exemplo n.º 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")
Exemplo n.º 2
0
 def test_zoo_tend_animal_no_budget(self):
     z = Zoo("Zoo", 250, 2, 2)
     z.add_animal(Lion("John", "m", 2), 100)
     z.add_animal(Tiger("Bill", "f", 4), 100)
     res = z.tend_animals()
     self.assertEqual(
         res, "You have no budget to tend the animals. They are unhappy.")
Exemplo n.º 3
0
 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")
Exemplo n.º 4
0
def read_file_csv(file_name):
    list_of_zoos = []
    with open(file_name, 'r') as csv_file:

        reader = csv.reader(csv_file)
        for row in reader:
            list_of_zoos.append(Zoo(row[0], int(row[1]), int(row[2])))
        return list_of_zoos
Exemplo n.º 5
0
 def test_zoo_init(self):
     z = Zoo("My Zoo", 1500, 6, 10)
     self.assertEqual(z._Zoo__animal_capacity, 6)
     self.assertEqual(z._Zoo__workers_capacity, 10)
     self.assertEqual(z._Zoo__budget, 1500)
     self.assertEqual(z.name, "My Zoo")
     self.assertEqual(z.animals, [])
     self.assertEqual(z.workers, [])
Exemplo n.º 6
0
 def test_zoo_tend_animal_success(self):
     z = Zoo("Zoo", 500, 2, 2)
     z.add_animal(Lion("John", "m", 2), 100)
     z.add_animal(Tiger("Bill", "f", 4), 100)
     res = z.tend_animals()
     self.assertEqual(z._Zoo__budget, 205)
     self.assertEqual(
         res,
         "You tended all the animals. They are happy. Budget left: 205")
Exemplo n.º 7
0
 def test_animal_status(self):
     z = Zoo("My Zoo", 500, 3, 3)
     z.add_animal(Lion("Leo", "Male", 3), 100)
     z.add_animal(Tiger("Tigy", "Female", 4), 100)
     z.add_animal(Cheetah("Chi", "Female", 2), 100)
     res = z.animals_status()
     self.assertEqual(
         res,
         "You have 3 animals\n----- 1 Lions:\nName: Leo, Age: 3, Gender: Male\n----- 1 Tigers:\nName: Tigy, Age: 4, Gender: Female\n----- 1 Cheetahs:\nName: Chi, Age: 2, Gender: Female"
     )
Exemplo n.º 8
0
 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"
     )
Exemplo n.º 9
0
    def create_zoo(self, owner_name: str) -> Optional[Zoo]:
        zoo_configs: Dict[
            TCityName, ZooConfiguration] = ZOOsConfigBuilder().get_configs()

        config: ZooConfiguration = zoo_configs.get(self.name)
        if not config or not config.is_open_to_public:
            return None

        zoo_outline: ZooOutline = config.get_outline(owner_name, zoo_size=130)
        return Zoo(zoo_outline)
Exemplo n.º 10
0
    def test_requirements(self):
        zoo = Zoo()
        cage1 = Cage()
        cage2 = Cage()

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

        self.assertEqual(
            zoo.number_of_cages(), 2
        )  # At any time, you should be able to find out how many cages are in the zoo.

        lion = Lion()
        hyena = Hyena()
        gazelle = Gazelle()
        wildebeest = Wildebeest()

        cage1.add_animal(lion)
        cage2.add_animal(gazelle)

        self.assertEqual(cage1.contents,
                         [lion])  # Put different animals in the cages
        self.assertTrue(
            lion.species)  # Each animal should be of a particular species
        self.assertTrue(
            lion.name
        )  # Each animal should have a name given to them by the zookeeper

        cage1.add_animal(hyena)
        cage2.add_animal(wildebeest)

        self.assertEqual(
            cage1.contents,
            [lion, hyena])  # Find out which animals are in a particular cage
        self.assertEqual(cage2.contents,
                         [gazelle, wildebeest
                          ])  # Find out which animals are in a particular cage

        with patch("builtins.print") as mock_print:
            prey_cage = Cage()

            predator = Lion(name='Predator')
            prey = Gazelle(name='Prey')

            prey_cage.add_animal(prey)
            prey_cage.add_animal(predator)

            mock_print.assert_called_once_with("Predator ate Prey.")
Exemplo n.º 11
0
Arquivo: main.py Projeto: skpai/oop
def main():
    a = Animal("cat", 1, 1)
    a.se_deplacer()
    s = Serpent("ss", 1, 1)
    s.se_deplacer()
    o = Oiseau("ss", 1, 1, 100)
    print(o.altmax)
    o.altmax = 150
    print(o.altmax)
    o.se_deplacer()
    o.dosomething()
    z = Zoo([s, o])
    z.dosomething()
    print(z)
    z.add_animal(a)
    print(z)
    print(z + z)
Exemplo n.º 12
0
    def test_requirements(self):
        """ Creates zoo and cages: """
        zoo = Zoo()
        cage_1 = Cage()
        cage_2 = Cage()

        """ Creation of animals: """
        mouse = Mouse()
        wildcat = WildCat()
        lion = Lion()

        """ Attempt to add objects that are not cages to a zoo """
        zoo.add_cages([mouse])
        self.assertFalse(zoo.cages, [mouse])

        """ Tests zoo with empty cages """
        self.assertEqual(cage_1.n_of_animals(), 0)
        zoo.add_cages([cage_1, cage_2])        
        self.assertEqual(zoo.cages, [cage_1, cage_2])

        """ Multiple addition of animals among repeated ones """
        cage_1.add_animals([mouse, mouse, lion, lion, mouse])
        # Set up to test more than one duplicated animal and different orders
        self.assertEqual(cage_1.animals_list, [mouse, lion])

        """ Tests zoo attributes """
        zoo.cages = []
        zoo.add_cages([cage_1, cage_2])
        self.assertEqual(zoo.cages, [cage_1, cage_2])
        self.assertEqual(zoo.n_of_cages(), 2)
        self.assertEqual(zoo.n_of_animals(), 2)

        """ Tests competition between prey and predator """
        cage_2.add_animals([mouse, wildcat, lion])
        self.assertEqual(cage_2.animals_list, [lion])

        """ Tests if animal already in another cage """
        # ----- Should I do it?

        """ Attempt to add objects that are not animals to a cage """
        cage_1.animals_list = []
        cage_1.add_animals([zoo])
        self.assertFalse(cage_1.animals_list, [zoo])
Exemplo n.º 13
0
ts = []
num_ts = 0
input_size = 0
output_size = 0
learning_rate = 0.0

if __name__ == "__main__":

    # initialise global variables

    SRC = 'big'  # default source is big dataset

    if len(sys.argv) >= 2: SRC = sys.argv[1]  # take user source

    # get questions and answers from the Zoo class
    Z = Zoo('data/' + SRC + '.csv')
    qs = Z.questions
    num_qs = len(qs)
    ts = Z.targets
    num_ts = len(ts)

    # hardcoded question limits for each dataset (+1 for last question guess)
    if SRC == 'big': question_limit = 13 + 1
    elif SRC == 'medium': question_limit = 6 + 1
    elif SRC == 'small': question_limit = 5 + 1
    elif SRC == 'micro': question_limit = 4 + 1
    else: question_limit = len(qs)

    # input and output size for nn are equal to the num qs and num ts respectively
    input_size = len(qs)
    output_size = len(ts)
Exemplo n.º 14
0
from animals import Bear
from zoo import Zoo
from food import Food
from errors import PositiveValueError

food = Food('Honey', 'Sweet')
name = 'Faust'
# age = int(input('Enter age:'))
age = 3.5
feature = (3, )
bear = Bear(name, age, food, feature)
# zoo = Zoo([])
zoo = Zoo()
zoo.animals.append(bear)

print(zoo)
print(zoo.animals)
Exemplo n.º 15
0
from zoo import Zoo
from animals import animal_list
from menu_functions import split, add_animals, info

life_like_a_zoo = Zoo()

running = True
while running:
    print('\nWelcome to my zoo!')
    info()
    action = input('Please enter the number: ')
    if action == '1':
        if life_like_a_zoo.free_area == 0:
            print('Unfortunately there is no free space left at the zoo :(')
        else:
            print(f'Available space: {life_like_a_zoo.free_area} sq.m')
            corral_area = input(
                'Please enter the amount of area that you want to highlight for the corral: '
            )
            animals_type = input(
                'Please enter the type of the animals that corral is created for\n'
                '1. Herbivore\n'
                '2. Predator\n'
                ':')
            if animals_type == '1':
                life_like_a_zoo.create_corral(int(corral_area), 'herbivore')
            elif animals_type == '2':
                life_like_a_zoo.create_corral(int(corral_area), 'predator')
            else:
                print('Oops,something went wrong...')
    if action == '2':
Exemplo n.º 16
0
 def test_accommodate(self):
     new_zoo = Zoo(1, 5)
     new_zoo.accommodate("tiger", 6, "misho", "male", 20)
     self.assertEqual(len(new_zoo.animals), 1)
Exemplo n.º 17
0
 def test_zoo_profit(self):
     z = Zoo("Mine", 250, 2, 2)
     z.profit(250)
     self.assertEqual(z._Zoo__budget, 500)
Exemplo n.º 18
0
 def test_zoo_add_animal_no_space(self):
     z = Zoo("My Zoo", 1500, 0, 10)
     res = z.add_animal(Lion("Neo", "Male", 2), 1000)
     self.assertEqual(res, "Not enough space for animal")
     self.assertEqual(len(z.animals), 0)
     self.assertEqual(z._Zoo__budget, 1500)
Exemplo n.º 19
0
from zoo import Zoo, Cat

if __name__ == '__main__':
    # 实例化动物园
    z = Zoo('时间动物园')
    # 实例化一只猫,属性包括名字、类型、体型、性格
    cat1 = Cat('大花猫 1', '食肉', '小', '温顺')
    # 增加一只猫到动物园
    z.add_animal(cat1)
    # 动物园是否有猫这种动物
    have_cat = hasattr(z, 'Cat')
Exemplo n.º 20
0
from lion import Lion
from tiger import Tiger
from cheetah import Cheetah
from keeper import Keeper
from caretaker import Caretaker
from vet import Vet
from 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),
Exemplo n.º 21
0
>>> gold_fish.age_in_months
2
>>> gold_fish.make_sound() # Prints
"Hum Hum"
>>> gold_fish.breathe() # Prints
"Breathe oxygen from water"

Hint: You can remove the duplication of breathe by using inheritance appropirately.
# Zoo
A Zoo contains different types of animals which are mentioned above. Zoo has food reserve to feed animals.

Write a Zoo class to implement this need and has the following features.

add_food_to_reserve - Updates the amount of food in reserve
>>> from zoo import Zoo
>>> zoo = Zoo()
>>> zoo.reserved_food_in_kgs
0
>>> zoo.add_food_to_reserve(10000000)
>>> zoo.reserved_food_in_kgs
10000000

count_animals should return all the animals count in that zoo
>>> zoo.count_animals()
0

add_animal - should add a new animal to the zoo
>>> gold_fish = GoldFish(age_in_months=1, breed="Nemo", required_food_in_kgs=0.5)
>>> zoo.add_animal(gold_fish)
>>> zoo.count_animals()
1
Exemplo n.º 22
0
 def test_zoo_fire_worker_unsuccessful(self):
     z = Zoo("Zoo", 1500, 1, 1)
     res = z.fire_worker("K")
     self.assertEqual(res, "There is no K in the zoo")
     self.assertEqual(z.workers, [])
Exemplo n.º 23
0
 def test_zoo_add_animal_success(self):
     z = Zoo("My Zoo", 1500, 6, 10)
     res = z.add_animal(Lion("Neo", "Male", 2), 1000)
     self.assertEqual(res, "Neo the Lion added to the zoo")
     self.assertEqual(len(z.animals), 1)
     self.assertEqual(z._Zoo__budget, 500)
Exemplo n.º 24
0
 def test_zoo_hire_worker_no_space(self):
     z = Zoo("Some Zoo", 1500, 1, 0)
     res = z.hire_worker(Vet("I am Vet", 20, 500))
     self.assertEqual(res, "Not enough space for worker")
     self.assertEqual(len(z.workers), 0)
     self.assertEqual(z._Zoo__workers_capacity, 0)
Exemplo n.º 25
0
 def test_zoo_hire_worker_success(self):
     z = Zoo("Some Zoo", 1500, 1, 1)
     res = z.hire_worker(Vet("I am Vet", 20, 500))
     self.assertEqual(res, "I am Vet the Vet hired successfully")
     self.assertEqual(len(z.workers), 1)
     self.assertEqual(z._Zoo__workers_capacity, 1)
Exemplo n.º 26
0
from zoo import Zoo
from time import sleep

z = Zoo()

while True:

    sleepval = 0.00001

    for x in range(z.NODE_COUNT):

        z.set_node(x, [255, 0, 0])
        z.send_frame()

        sleep(sleepval)

        z.set_node(x, [0, 255, 0])
        z.send_frame()

        sleep(sleepval)

        z.set_node(x, [0, 0, 255])
        z.send_frame()

        sleep(sleepval)

        z.set_node(x, [255, 255, 255])
        z.send_frame()

        sleep(sleepval)
Exemplo n.º 27
0
 def setUp(self):
     self.zoopark = Zoo(2, 5)
     self.puh_panda = Animal("panda", 3, "Puh", "male", 100)
Exemplo n.º 28
0
 def test_accommodate_no_same_species(self):
     new_zoo = Zoo(1, 5)
     new_zoo.accommodate("pantera", 6, "misho", "male", 20)
     self.assertEqual(len(new_zoo.animals), 0)
Exemplo n.º 29
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, [])
Exemplo n.º 30
0
 def test_zoo_add_animal_no_budget(self):
     z = Zoo("My Zoo", 500, 6, 10)
     res = z.add_animal(Lion("Neo", "Male", 2), 1000)
     self.assertEqual(res, "Not enough budget")
     self.assertEqual(len(z.animals), 0)
     self.assertEqual(z._Zoo__budget, 500)