コード例 #1
0
from arboretum import Arboretum
from actions.annex import annex_habitat
from actions.report import build_facility_report
from helpers import print_banner

# ANIMAL ACTIONS
from actions.release_animal import release_animal
from actions.feed_animal import feed_animal

# PLANT ACTIONS
from actions.cultivate_plant import cultivate_plant


keahua = Arboretum("Keahua Arboretum", "123 Paukauila Lane")


def build_menu():
    '''
    Title Menu with options list
    '''
    print_banner()
    print("MAIN MENU:")
    print("")
    # MAIN MENU
    print("1. Annex Biome")
    print("2. Release New Animal")
    print("3. Feed Animal")
    print("4. Cultivate New Plant")
    print("5. Show Arboretum Report")
    print("6. Exit")
    print("")
コード例 #2
0
import os
from arboretum import Arboretum
# from actions.release_animal import release_animal
# from actions.report import build_facility_report
# from environments import Habitat

avail_animals = ["Gold Dust Day Gecko", "River Dolphin", "Nene Goose", "Kikakapu", "Pueo", "'Ulae", "Ope'ape'a", "Happy-Face Spider"]
avail_plants = ["Mountain Apple Tree", "Silversword", "Rainbow Eucalyptus Tree", "Blue Jade Vine"]
avail_habitats = ["Mountain", "Swamp", "Grassland", "Forest", "River", "Coastline"]

keahua = Arboretum("Keahua Arboretum", "123 Paukauila Lane", avail_animals, avail_plants, avail_habitats)


def animal_menu():
    for animal in avail_animals:
        print(f"{avail_animals.index(animal) + 1}. {animal}")

    print("\nChoose animal")
    choice = input(">> ")
    return choice


def plant_menu():
    for plant in avail_plants:
        print(f"{avail_plants.index(plant) + 1}. {plant}")

    choice = input(">> ")
    return choice


def build_menu():
コード例 #3
0
import os
from arboretum import Arboretum
from environments import River, Swamp, Coastline, Forest, Grassland, Mountain
from animals import RiverDolphin, Gecko, Kikakapu
from actions.annex import annex_habitat
from actions.release_animal import release_animal
from actions.report import build_facility_report
from actions.feed import feed_animal
from actions.add_plant import add_plant

keahua = Arboretum("Keahua Arboretum", "123 Paukauila Lane")

keahua.add_biome(River("River 1"))
keahua.add_biome(River("River 2"))

keahua.add_biome(Coastline("Coastline 1"))
keahua.add_biome(Coastline("Coastline 2"))

keahua.add_biome(Swamp("Swamp 1"))
keahua.add_biome(Swamp("Swamp 2"))

keahua.add_biome(Forest("Forest 1"))
keahua.add_biome(Forest("Forest 2"))

keahua.add_biome(Grassland("Grassland 1"))
keahua.add_biome(Grassland("Grassland 2"))

keahua.add_biome(Mountain("Mountain 1"))
keahua.add_biome(Mountain("Mountain 2"))

keahua.rivers[0].add_animal(RiverDolphin())
def build_feeding_animal_menu(arboretum, animal_list, menu, error_message,
                              message_text):
    """
    Creates Select Animal Menu
    """
    os.system('cls' if os.name == 'nt' else 'clear')

    animal_instance_list = ["" for i in animal_list]
    print(''' +-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-+
 |           Choose an animal to feed              |
 +-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-+ ''')

    if error_message != "":
        print()
        print(f"{error_message}")
    print()
    print("0. Main Menu")
    for i, animal in enumerate(animal_list):
        animal_instance_list[i] = animal()
        print(f"{i + 1}. {animal_instance_list[i].species}")

    if message_text != "":
        print(f"\n{message_text}")
        message_text = ""
    choice = input(">")

    all_animals_all_biomes = Arboretum.animals(arboretum)

    geckos = []
    geese = []
    kikakapus = []
    opeapeas = []
    pueos = []
    river_dolphins = []
    spiders = []
    ulaes = []

    list_of_animal_lists = [
        geckos, geese, kikakapus, opeapeas, pueos, river_dolphins, spiders,
        ulaes
    ]

    for animal in all_animals_all_biomes:
        if animal.species == "Gold Dust Day Gecko":
            geckos.append(animal)
        if animal.species == "Nene Goose":
            geese.append(animal)
        if animal.species == "Kīkākapu":
            kikakapus.append(animal)
        if animal.species == "Ope'ape'a":
            opeapeas.append(animal)
        if animal.species == "Pueo":
            pueos.append(animal)
        if animal.species == "River Dolphin":
            river_dolphins.append(animal)
        if animal.species == "Hawaiian Happy-Face Spider":
            spiders.append(animal)
        if animal.species == "'Ulae":
            ulaes.append(animal)

    try:
        choice = int(choice)

        selected_list = list_of_animal_lists[int(choice) - 1]

        if choice == 0:
            menu()
        elif len(selected_list) == 0:
            error_message = "****  There does not appear to be any of this type of animal  ****\n \n          ****  Please choose another  ****\n"
            message_text = "\nChoose an animal"
            build_feeding_animal_menu(arboretum, animal_list, menu,
                                      error_message, message_text)
        elif choice <= len(animal_instance_list) and choice > 0:
            filter_animals(arboretum,
                           choice,
                           menu,
                           animal_list,
                           selected_list,
                           list_of_animal_lists,
                           message_text="\nwhich animal do you want to feed?")
    except ValueError:
        message_text = "*  Please input one of the numbers above  *"
        restart_menu = build_feeding_animal_menu(arboretum, animal_list, menu,
                                                 error_message, message_text)
        return restart_menu
    except IndexError:
        message_text = "*  Please input one of the numbers above  *"
        build_feeding_animal_menu(arboretum, animal_list, menu, error_message,
                                  message_text)
    except TypeError:
        message_text = "*  Please input one of the numbers above  *"
        build_feeding_animal_menu(arboretum, animal_list, menu, error_message,
                                  message_text)
    else:
        message_text = "*  Please input one of the numbers above  *"