예제 #1
0
파일: main.py 프로젝트: leohaskell/Zoo
def main():
    db = Database("zoo.db")
    zoo = Zoo(50, 1000000000, db)
    simulation = Simulation(zoo)
    print("welcome to our zoo! enter help to get available commands")

    while True:
        commands = input("what'd you like to do? ").split(' ')
        command = commands[0]
        args = commands[1:]
        if command == 'help':
            print(instructions())
        elif command == 'simulate':
            try:
                simulation.simulate(*args)
            except AttributeError:
                print('\n'.join(["wrong command or wrong arguments entered!",
                    "maybe enter help again :)"]))
        elif command == 'exit':
            print('bye')
            exit(0)
        else:
            try:
                print(zoo.__getattribute__(command)(*args))
            except (TypeError, AttributeError):
                print('\n'.join(["wrong command or wrong arguments entered!",
                        "maybe enter help again :)"]))

    sm = Simulation(zoo)
    sm.simulation('months', 2)