Example #1
0
from movements import (IWalk, ISlither, ISwim, IFly, IDig)
from habitats import (Aquarium, FlyCage, Atrium, LandCage, Terrarium,
                      WaterCage)

andy = Ant("Andy", "Fire Red")
barry = BettaFish("Barry", "Blue")
calvin = Copperhead("Calvin", 'Camo')
earl = EarthWorm("Earl", "Mud Brown")
frita = Finch("Frita", "Yellow")
grandpa = Gerbil("Granpa", "Brown")
milton = Mouse("milton", "Orange")
paulina = Parakeet("Paulina", "Purple")
rayray = Rattlesnake("Ray-Ray", "Camo")
tim = Terrapin("Tim", "green")

aqua = Aquarium()
atri = Atrium()
terra = Terrarium()
flyCage = FlyCage()
landCage = LandCage()
waterCage = WaterCage()

#Uncomment by section

#SECTION 1_____________________________________

# #Aquarium adds
# aqua.add_animal(barry)
# aqua.add_animal(tim)

# #Atrium Adds
from animals import Penguin, PaintedDog
from habitats import Habitat, Aquarium

Flipper = Penguin("Flipper")
Flipper.swim()
Flipper.run()

Picasso = PaintedDog("Picasso")
Picasso.run()

SanDiegoAquarium = Aquarium("San Diego Aquarium")
SanDiegoAquarium.add_swimmer_pythonic(Flipper)
SanDiegoAquarium.add_swimmer_pythonic(Picasso)
SanDiegoAquarium.add_swimmer_type_check(Picasso)

print(f"The following animals live in San Diego Aquarium:")
for animal in SanDiegoAquarium.animals:
    print(animal)
Example #3
0
from animals import Penguin, PaintedDog
from movements import IWalking
from habitats import Aquarium

bob = Penguin("Bob")

print(bob)
print(f"This is Bob: {bob}")

print("Bob's legs:", bob.legs)
bob.run()
print("Bob's swim speed: ", bob.swim_speed)
bob.swim()

jim = Penguin("Jim")

ralph = PaintedDog("Ralph")

seaworld = Aquarium("Sea World")
print(seaworld.__len__())

seaworld.add_animal(bob)
seaworld.add_animal(jim)
seaworld.add_animal(ralph)

print(seaworld.name)
for animal in seaworld.animals:
    print(animal)
    
Example #4
0
from animals import Penguin, PaintedDog
from habitats import Habitat, Aquarium

# bob = Penguin("Bob")

# Create a penguin
bob = Penguin("Bob")
bob.run()
bob.swim()

ralph = PaintedDog("Ralph")

# Create a habitat
seaworld = Aquarium("Sea World")
# seaworld.add_animal(bob)
# seaworld.add_animal(ralph)

for animal in seaworld.animals:
    print(animal)

seaworld.add_swimmer_pythonic(bob)
seaworld.add_swimmer_pythonic(ralph)
# seaworld.add_swimmer_type_check(ralph)

for animal in seaworld.animals:
    print(f'{animal} lives in Sea World')
bob = Penguin("Bob")
ralph = PaintedDog("Ralph")

print(bob.walk())
print(bob.swim())

seaworld = Habitat("Sea World")
seaworld.add_animal(bob)
seaworld.add_animal(ralph)

for animal in seaworld.animals:
    print(animal)

#***** refactored after adding type checking *********#

bob = Penguin("Bob")
ralph = PaintedDog("Ralph")

seaworld = Aquarium("Sea World")
seaworld.add_swimmer_pythonic(bob)
seaworld.add_swimmer_pythonic(ralph)
seaworld.add_swimmer_type_check(ralph)

for animal in seaworld.animals:
    print(f'{animal} lives in Sea World')

# Ralph the Painted Dog can't swim, so please do not try to put it in the Sea World habitat
# Ralph the Painted Dog can't swim, so please do not try to put it in the Sea World habitat
# Bob the Penguin lives in Sea World
Example #6
0
from animals import PaintedDog
from animals import Penguin
from habitats import Habitat
from habitats import Aquarium

Bob = Penguin("Bob")
# print(Bob)
# Bob.run()
# Bob.swim()

Ralph = PaintedDog("Ralph")
# print(Ralph)

seaworld = Aquarium("Sea World")
seaworld.add_swimmer_pythonic(Bob)
seaworld.add_swimmer_pythonic(Ralph)
seaworld.add_swimmer_type_check(Ralph)


for animal in seaworld.animals:
    print(animal)
Example #7
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)
from animals import Penguin, PaintedDog
from habitats import Habitat, Aquarium

pingu = Penguin('pingu')
dog = PaintedDog('ralph')

ocean = Aquarium('ocean')

ocean.add_swimmer_type_check(pingu)
ocean.add_swimmer_type_check(dog)

for animal in ocean.animals:
    print(animal)
Example #9
0
wingsy = Parakeet("Wingsy")
snakey = Copperhead("Snakey")
fishy = BettaFish("Fishy")

wormy.digging()
snakey.slithering()
fishy.swim()
doggy.run()
waddles.run()
waddles.swim()
wingsy.flying()

print(wingsy.__dict__)
print(wormy.__dict__)

seaworld = Aquarium("Sea World")
seaworld.add_swimmer_type_check(waddles)
seaworld.add_swimmer_type_check(fishy)
seaworld.add_swimmer_type_check(snakey)

skyworld = Aviary("Sky World")
skyworld.add_flier_type_check(wingsy)

landworld = Terrestrial("Land World")
landworld.add_walking_type_check(snakey)
landworld.add_walking_type_check(doggy)
landworld.add_walking_type_check(waddles)
landworld.add_walking_type_check(wormy)

dirtpot = DirtPot("Dirt Pot")
dirtpot.add_digger_type_check(wormy)