Difference between revisions of "ParserUsage.py"
From WLCS
(Created page with "import menu print ("This program will test the Parser class") print ("\nFirst, the parse() method will be tested") print ("Enter q to quit") print() menu.printCommands() print(...") |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | <syntaxhighlight lang="Python"> | ||
import menu | import menu | ||
Line 37: | Line 38: | ||
print ("\nNext, the askYesNoQuestion() will be tested") | print ("\nNext, the askYesNoQuestion() will be tested") | ||
answer = menu.askYesNoQuestion("Enter either yes or no") | answer = menu.askYesNoQuestion("Enter either yes or no") | ||
− | print ("Result was " + answer) | + | print ("Result was " + str(answer)) |
+ | </syntaxhighlight> |
Latest revision as of 14:18, 6 May 2013
import menu
print ("This program will test the Parser class")
print ("\nFirst, the parse() method will be tested")
print ("Enter q to quit")
print()
menu.printCommands()
print()
while True:
result = menu.parse()
if result == menu.NORTH:
print ("You entered north")
elif result == menu.EAST:
print ("You entered east")
elif result == menu.SOUTH:
print ("You entered south")
elif result == menu.WEST:
print ("You entered west")
elif result == menu.ATTACK:
print ("You entered attack")
elif result == menu.LOOK:
print ("You entered look")
elif result == menu.GET:
print ("You entered get")
elif result == menu.QUIT:
print ("You entered quit")
elif result == menu.DO_NOT_UNDERSTAND:
print ("You entered an unknown command")
else:
print ("Your parse() method returned an invalid value.\nTHIS IS A BUG IN YOUR PROGRAM.")
if result == menu.QUIT:
break
print ("\nNext, the askYesNoQuestion() will be tested")
answer = menu.askYesNoQuestion("Enter either yes or no")
print ("Result was " + str(answer))