#08/10/09
#This program will provide control
#functions for a virtual Battlebot
#Final Lab - Programming a Robot Battlebot
def main():
endProgram = False
ammunition = 5
fuel = 200.0
totalFeet = 0
enemyDistance = 200
while not endProgram:
print 'Menu Selections: '
print '1 - Fire Weapon '
print '2 - Move Forward '
print '3 - Move Backward '
print '4 - Exit '
choice = input('Enter your selection ')
if choice == 1:
ammunition = fire(ammunition)
elif choice == 2:
fuel = moveFor(fuel)
elif choice == 3:
moveBackward = moveBack(fuel)
elif int(choice) == 4:
print 'Goodbye!'
endProgram()
else:
print 'Error: Invalid selection.'
def fire(ammunition):
if ammunition >= 1:
fire = attack()
else:
print 'You are out of ammunition!'
ammunition = ammunition - 1
print ammunition
return ammunition
def moveFor(fuel):
print fuel
moveFor = input ('How far would you like to move?')
if moveFor <= fuel:
fuel = fuel - moveFor
elif fuel == 0:
print 'You have no fuel left!'
elif moveFor > fuel :
print 'You need more fuel to move!'
print fuel
return fuel
def moveBack(fuel):
print fuel
moveBack = input ('How far would you like to move?')
if moveBack <= fuel:
fuel = fuel - moveBack
elif fuel == 0:
print 'You have no fuel left!'
elif moveBack > fuel:
print 'You need more fuel to move!'
print fuel
return fuel
def fuelLeft(fuel):
fuelLeft = (fuel - moveFor or fuel - moveBack)
def attack():
print 'How far away is the enemy? '
attackDis = input ('Enter distance in feet. ')
if attackDis <= 10:
print 'Enemy has been destroyed! '
return
elif attackDis <= 25:
print 'Enemy has been partially disabled. '
return
elif attackDis >= 26:
print 'The enemy has been unharmed! '
return
def endProgram():
print 'Y or N:'
true = raw_input('Do you wish to exit this program?')
if true == 'y' or true == 'Y':
quit()
elif true == 'n' or true == 'N':
print 'Welcome back.'
return
else:
print 'Error: Invalid selection.'
#calls main
main()
I can't get the endProgram to run!

New Topic/Question
Reply



MultiQuote


|