Quote:
| Originally Posted by b49P23TIvg Please use code tags---follow instructions at my signature for posting code. Thanks.
What part have you written? I take it you didn't write
Code:
#hint: the keyword to break out of a loop was used earlier
Maybe you wrote
Code:
#this isn't code
15 burgers left
numBurgersLeft = 15
5 burgers ordered
howManyOfItem = 5
I don't see a clear way to guide you. I can't bypass the next-to-useless order number. You don't store the order by number and pass it back to the chef. The order number should be automatically assigned, unless it's zero. The assignment seems unreasonable because I wouldn't ask so many damn questions. My main program would probably read
Code:
def main():
while orders():
pass
Simple. All functions short and simple. Use many functions. |
Okay, I have narrowed my code down to this:
#Mark Rourke, Mitch Lavalle
#Dec 04, 2012
#Global Constants
#Constant Integer MAX_QTY
MAX_QTY = 20
#Constant Real TAX_RATE
TAX_RATE = .13
def main():
#Integer Constant STOP = 0`
STOP = 0
print ("======================== NEW ORDER==========================")
#get the order number
#validate inside the function
#make sure number is >= 0
orderNumber = getOrderNumber()
#break exits out of the loop it is placed in
#if the input is 0, we want to stop the program
while (orderNumber != 0):
burgersLeft = 0
friesLeft = 0
sodasLeft = 0
#print out the order number
print ("START ORDER:") + str(orderNumber)
#keep getting items for this order until the user wants to end the order
#set initial quantities of items
#for EACH order, the limit is 20
menuItem = showMenu()
#ordering stuff from the menu
while (menuItem!= 4):
#show user menu, get menu selection from them
#inside the function, we get input
#validate the input (1, 2, 3, 4)
#return that value
#menuItem 1 Yum Yum Burger
#menuItem 2 Greasy Yum Fries
#get how many of the item we want
#i.e. if menuItem is 1 (Yum Yum Burger) and howManyOfItem is 2, then the person wants 2 Yum Yum Burgers
#need to tell person how many they can order and prompt for number
#need to check if quantity ordered is allowed
if menuItem == 1: #burger
#prompting taken care of in getitem
#passes back number that they want
#0 through number left of that item
burgersLeft = getItem(1,MAX_QTY - burgersLeft)
elif menuItem == 2:
#first parameter is the item
#second parameter is the number left
friesLeft = getItem(2,MAX_QTY - friesLeft)
elif menuItem == 3:
sodasLeft = getItem(3,MAX_QTY - sodasLeft)
else: break
#menuItem is 4 here. We want to end the order.
#what do we put here to end the order, i.e. break out of loop?
#hint: the keyword to break out of a loop was used earlier
#subtract from the quantity left
#need to know which item it is (so we know which quantity to subtract from)
#then subtract number ordered
if menuItem == 1:
#want this to be new numBurgersLeft <----
# = <- assign values
#assignment operator
# left hand side: variable, not 5, "hello"
# right hand side: value, 5, "hello", variable
burgersOrdered = burgersLeft - MAX_QTY
burgersLeft = burgersLeft + burgersOrdered
elif menuItem == 2:
friesOrdered = friesLeft - MAX_QTY
friesLeft = friesLeft + friesOrdered
elif menuItem == 3:
sodasOrdered = sodasLeft - MAX_QTY
sodasLeft = sodasLeft + sodasOrdered
#Calculate the cost of each item
costOfBurgers = calculateCost (1, burgersOrdered)
costOfFries = calculateCost (2, friesOrdered)
costOfSodas = calculateCost (3, sodasOrdered)
totalCost = CalculateTotalCost(1,2,3 + totalTax)
tax = calculateTax(totalCost * .13)
finalCost = calculateFinalPrice(TotalCost + tax)
I know it needs work but i dont know what to do, can you please give me some functions to work with?