Ejemplo n.º 1
0
 def get_fish(fish_type, fish_name, fish_species, price):
     fish = None
     if fish_type == 'FreshwaterFish':
         fish = FreshwaterFish(fish_name, fish_species, price)
     elif fish_type == 'SaltwaterFish':
         fish = SaltwaterFish(fish_name, fish_species, price)
     return fish
Ejemplo n.º 2
0
 def add_fish(self, aquarium_name, fish_type, fish_name, fish_species,
              price):
     aquarium = self.__get_aquarium_by_name(aquarium_name)
     if fish_type == 'FreshwaterFish':
         fish_object = FreshwaterFish(fish_name, fish_species, price)
     elif fish_type == 'SaltwaterFish':
         fish_object = SaltwaterFish(fish_name, fish_species, price)
     else:
         return f"There isn't a fish of type {fish_type}."
     return aquarium.add_fish(fish_object)
Ejemplo n.º 3
0
    def add_fish(self, aquarium_name: str, fish_type: str, fish_name: str,
                 fish_species: str, price: float):
        valid_fish_types = ["FreshwaterFish", "SaltwaterFish"]
        if fish_type not in valid_fish_types:
            return f"There isn't a fish of type {fish_type}."
        fish = FreshwaterFish(fish_name, fish_species, price) if fish_type == "FreshwaterFish" \
            else SaltwaterFish(fish_name, fish_species, price)
        if aquarium_name in map(lambda a: a.name, self.aquariums):
            aquarium = [a for a in self.aquariums
                        if a.name == aquarium_name][0]

            aquarium.add_fish(fish)
Ejemplo n.º 4
0
    def add_fish(self, aquarium_name: str, fish_type: str, fish_name: str,
                 fish_species: str, price: float):
        if fish_type == 'SaltwaterFish':
            fish = SaltwaterFish(fish_name, fish_species, price)
            for i in self.aquariums:
                if i == aquarium_name:
                    return i.add(fish)
        elif fish_type == 'FreshwaterFish':
            fish = FreshwaterFish(fish_name, fish_species, price)
            for i in self.aquariums:
                if i == aquarium_name:
                    return i.add(fish)

        return f"There isn't a fish of type {fish_type}"
Ejemplo n.º 5
0
 def add_fish(self, aquarium_name: str, fish_type: str, fish_name: str, fish_species: str, price: float):
     if fish_type == "FreshwaterFish":
         fish = FreshwaterFish(fish_name, fish_species, price)
     elif fish_type == "SaltwaterFish":
         fish = SaltwaterFish(fish_name, fish_species, price)
     else:
         return f"There isn't a fish of type {fish_type}."
     try:
         aquarium = [a for a in self.aquariums if aquarium_name == a.name][0]
         # if aquarium.water != fish.water:
         #     return "Water not suitable."
         return aquarium.add_fish(fish)
     except IndexError:
         return
Ejemplo n.º 6
0
 def add_fish(self, aquarium_name: str, fish_type: str, fish_name: str,
              fish_species: str, price: float):
     aquarium = [
         aquarium for aquarium in self.aquariums
         if aquarium.name == aquarium_name
     ][0]
     if fish_type == 'FreshwaterFish':
         fish = FreshwaterFish(fish_name, fish_species, price)
         return aquarium.add_fish(fish)
     elif fish_type == 'SaltwaterFish':
         fish = SaltwaterFish(fish_name, fish_species, price)
         return aquarium.add_fish(fish)
     else:
         return f'There isn\'t a fish of type {fish_type}.'
Ejemplo n.º 7
0
 def add_fish(self, aquarium_name: str, fish_type: str, fish_name: str,
              fish_species: str, price: float):
     if fish_type != "FreshwaterFish" and fish_type != "SaltwaterFish":
         return f"There isn't a fish of type {fish_type}."
     else:
         if fish_type == "FreshwaterFish":
             fish = FreshwaterFish(fish_name, fish_species, price)
         else:
             fish = SaltwaterFish(fish_name, fish_species, price)
         aquarium = \
             [a for a in self.aquariums if a.name == aquarium_name][0]
         if "Freshwater" in aquarium.__class__.__name__ and "Freshwater" in fish.__class__.__name__:
             return aquarium.add_fish(fish)
         elif "Saltwater" in aquarium.__class__.__name__ and "Saltwater" in fish.__class__.__name__:
             return aquarium.add_fish(fish)
         else:
             return "Water not suitable."
Ejemplo n.º 8
0
    def add_fish(self, aquarium_name: str, fish_type: str, fish_name: str, fish_species: str, price: float):
        valid_fish_type = ('FreshwaterFish', 'SaltwaterFish')
        valid_aquarium_type = ('FreshwaterAquarium', 'SaltwaterAquarium')

        if fish_type not in valid_fish_type:
            return f"There isn't a fish of type {fish_type}."

        aquarium = self.find_aquarium_by_name(aquarium_name)

        if fish_type == valid_fish_type[0] and aquarium.__class__.__name__ == valid_aquarium_type[0]:
            new_fish = FreshwaterFish(fish_name, fish_species, price)
            return aquarium.add_fish(new_fish)
        elif fish_type == valid_fish_type[1] and aquarium.__class__.__name__ == valid_aquarium_type[1]:
            new_fish = SaltwaterFish(fish_name, fish_species, price)
            return aquarium.add_fish(new_fish)
        else:
            return f"Water not suitable."
Ejemplo n.º 9
0
    def add_fish(self, aquarium_name: str, fish_type: str, fish_name: str,
                 fish_species: str, price: float):
        if fish_type not in ["FreshwaterFish", "SaltwaterFish"]:
            return f"There isn't a fish of type {fish_type}."
        try:
            temp_a = [a for a in self.aquariums if a.name == aquarium_name][0]

            if fish_type == "FreshwaterFish" and temp_a.__class__.__name__ == 'FreshwaterAquarium':
                return temp_a.add_fish(
                    FreshwaterFish(fish_name, fish_species, price))
            elif fish_type == "SaltwaterFish" and temp_a.__class__.__name__ == 'SaltwaterAquarium':
                return temp_a.add_fish(
                    SaltwaterFish(fish_name, fish_species, price))
            else:
                return "Water not suitable."
        except IndexError:
            pass
Ejemplo n.º 10
0
    def add_fish(self, aquarium_name: str, fish_type: str, fish_name: str,
                 fish_species: str, price: float):
        valid_fish_types = ["FreshwaterFish", "SaltwaterFish"]
        if fish_type not in valid_fish_types:
            return f"There isn't a fish of type {fish_type}"

        aquarium = [a for a in self.aquariums if a.name == aquarium_name][0]
        if aquarium.__class__.__name__ == "FreshwaterAquarium" and fish_type == "SaltwaterFish":
            return "Water not suitable"
        if aquarium.__class__.__name__ == "SaltwaterAquarium" and fish_type == "FreshwaterFish":
            return "Water not suitable"
        if aquarium.current_capacity <= 0:
            return "Not enough capacity"

        if fish_type == "SaltwaterFish":
            aquarium.add_fish(SaltwaterFish(fish_name, fish_species, price))
            return f"Successfully added {fish_type} to {aquarium_name}"
        if fish_type == "FreshwaterFish":
            aquarium.add_fish(FreshwaterFish(fish_name, fish_species, price))
            return f"Successfully added {fish_type} to {aquarium_name}"
Ejemplo n.º 11
0
    def add_fish(self, aquarium_name: str, fish_type: str, fish_name: str,
                 fish_species: str, price: float):
        if fish_type not in ["FreshwaterFish", "SaltwaterFish"]:
            return f"There isn't a fish of type {fish_type}."

        fish_created = ''
        if fish_type == "FreshwaterFish":
            fish_created = FreshwaterFish(fish_name, "Freshwater", price)

        elif fish_type == "SaltwaterFish":
            fish_created = SaltwaterFish(fish_name, "Saltwater", price)

        aquarium_found = [
            aq for aq in self.aquariums if aq.name == aquarium_name
        ]
        if aquarium_found:
            aquarium = aquarium_found[0]
            if len(aquarium.fish) >= aquarium.capacity:
                return f"Not enough capacity."
            elif fish_type != aquarium.aquarium_fish_type:
                return "Water not suitable"
            aquarium.add_fish(fish_created)
            return f"Successfully added {fish_type} to {aquarium_name}."
Ejemplo n.º 12
0
    def add_fish(self, aquarium_name: str, fish_type: str, fish_name: str,
                 fish_species: str, price: float):
        valid_fish_types = ('FreshwaterFish', 'SaltwaterFish')
        valid_aquarium_types = ('FreshwaterAquarium', 'SaltwaterAquarium')

        if fish_type not in valid_fish_types:
            return f'There isn\'t a fish of type {fish_type}.'

        aquarium = [a for a in self.aquariums if a.name == aquarium_name][0]

        if fish_type == valid_fish_types[
                0] and aquarium.__class__.__name__ == valid_aquarium_types[0]:
            new_fish = FreshwaterFish(name=fish_name,
                                      species=fish_species,
                                      price=price)
            return aquarium.add_fish(new_fish)
        elif fish_type == valid_fish_types[
                1] and aquarium.__class__.__name__ == valid_aquarium_types[1]:
            new_fish = SaltwaterFish(name=fish_name,
                                     species=fish_species,
                                     price=price)
            return aquarium.add_fish(new_fish)
        else:
            return 'Water not suitable.'
Ejemplo n.º 13
0
orn = Ornament()
plant = Plant()
orn_2 = Ornament()
# print(orn.__dict__)
# print(plant.__dict__)

dec_rep = DecorationRepository()
dec_rep.add(orn)
dec_rep.add(orn_2)
dec_rep.add(plant)
print(dec_rep.find_by_type("Ornament"))
print(dec_rep.__dict__)
dec_rep.remove(orn_2)
dec_rep.remove(orn_2)

fresh_water_fish = FreshwaterFish("Sladka", "Freshwater", 5.5)
salt_water_fish = SaltwaterFish("Salty", "Saltwater", 8.4)
fresh_water_fish_2 = FreshwaterFish("Freshy2", "FreshFish2", 7)
salt_water_fish_2 = SaltwaterFish("Salty_2", "Saltwater", 4)
fresh_aquarium = FreshwaterAquarium("FreshShitAquarium")
salt_aquarium = SaltwaterAquarium("SaltwaterShitAquarium")
print(fresh_aquarium.add_fish(fresh_water_fish))
fresh_aquarium.add_fish(salt_water_fish)
print(fresh_aquarium.add_fish(fresh_water_fish_2))
salt_aquarium.add_fish(salt_water_fish)
salt_aquarium.add_fish(salt_water_fish_2)
salt_aquarium.remove_fish(salt_water_fish_2)
salt_aquarium.add_decoration(orn)
salt_aquarium.add_decoration(plant)
print(salt_aquarium.__dict__)
fresh_water_fish.eat()
Ejemplo n.º 14
0
 def create_fish(fish_type, name, species, price):
     if fish_type == "FreshwaterFish":
         return FreshwaterFish(name, species, price)
     if fish_type == "SaltwaterFish":
         return SaltwaterFish(name, species, price)
Ejemplo n.º 15
0
from project.decoration.ornament import Ornament
from project.decoration.plant import Plant
from project.fish.base_fish import BaseFish
from project.controller import Controller

# Aquariums
from project.fish.freshwater_fish import FreshwaterFish
from project.fish.saltwater_fish import SaltwaterFish

b = BaseAquarium("Base", 10)
f = FreshwaterAquarium("FreshAQ")
s = SaltwaterAquarium("SaltAQ")

# Fish
fish1 = BaseFish("BaseF", "G", 10, 100)
fish2 = FreshwaterFish("FreshF", "FF", 200)
fish3 = SaltwaterFish("FreshF", "FF", 200)

# Decorations
decor1 = Ornament()
decor2 = Plant()

# Decor Repos
de = DecorationRepository()

# Controllers
co = Controller()

print(s.add_fish(fish2))
print(s.add_fish(fish2))
print(s.add_fish(fish3))