#10/04/18 #CommandTest.py #IT5014v4d: Programming Principles Project # from Command import Command #testing the features of the command class g = Command() g.get_command() print(g.command_entered) print(g.successful_input) print(g.error_message)
creds = CredentialList() ##################################################### print('\n' * 100) print(Command.leet_sauce) while True: continueLastSession = raw_input( 'Would you like to import the data from the last session? (y/n) ') if continueLastSession == 'y': session_file = raw_input('What file would you like to load from? ') print('Starting new session from ' + session_file) try: creds.import_file(session_file) break except IOError: print("That was an invalid path. Please try again.") break elif continueLastSession == 'n': print('Starting new Session...') break else: print('That was invalid input. Try again. ') ########################### while (True): new_cmd = Command.get_command(creds) new_cmd.execute_command()
# Command Test # by Lucian # 28/11/2019 from Command import Command from Ship import Ship command = Command() command.get_command() # test the success checker print("The success check result is:", command.success_check) # test the user command and error if command.success_check: print("The user command result is:", command.new_command) else: print("The error is:", command.error_message) # test the ship placement checker test_ships = [(0, 0), (1, 0), (2, 0)] # we need some ships to test with good_ship = Ship('h', (0, 4)) # this ship should work out_of_bounds = Ship('v', (100, 100)) # this ship is out of bounds overlapping = Ship('h', (0, 0)) # this ship is on top of an existing ship print("\nOut of bounds ship:") if not command.check(test_ships, out_of_bounds): # test out of bounds print("The error is:", command.error_message) else: print("It worked.")