Posted: Sat Nov 07, 2009 9:56 pm Post subject: Need help on Resturant Menu system
Hi. I'm trying to make a restaurant system. When you run it, it starts with the main menu. I have only worked on the Food menu option, so don't bother entering in options
2-6. The next thing that will appear is the actual food menu. Again, I have only worked on the first option, so enter in option 1. Here is one of my problems. If you noticed, I used the subtotal for a temporary answer. Meaning the program doesn't automatically add the order price with the old subtotal to get a new subtotal. I just don't know how to get it that way. Also, when you press 0 to exit, I don't know how to make a loop that goes all the way back to the main menu.
The main problem is really figuring out a more efficient way to do this system because it's obviously the opposite of efficient. Also, if there is anything wrong about the program, please please please tell me. I know 100% that there is though. Thank you for all your help and tips. I appreciate it.
Oh, and sorry if I am leaving out some important details you need to know. If I am, just tell me.
Turing:
var selection :string var selection2 :int var selection3 :real var subtotal :real var total :real var Exit :string var order1 :=2.00 var order2 :=2.00 var order3 :=0.75 var order4 :=1.00 var order5 :=1.25 var order6 :=1.25 var order7 :=1.00
loop put"Enter your selection number you want to order (Press 0 to exit): "..
get selection2
if selection2 =1then put"Enter your last subtotal here: "..
get subtotal
putskip put"Your subtotal now is $", order1 + subtotal
putskip elsif selection2 =2then put"Enter your last subtotal here: "..
get subtotal
putskip put"Your subtotal now is $", order2 + subtotal
putskip elsif selection2 =3then put"Enter your last subtotal here: "..
get subtotal
putskip put"Your subtotal now is $", order3 + subtotal
putskip elsif selection2 =4then put"Enter your last subtotal here: "..
get subtotal
putskip put"Your subtotal now is $", order4 + subtotal
putskip elsif selection2 =5then put"Enter your last subtotal here: "..
get subtotal
putskip put"Your subtotal now is $", order5 + subtotal
putskip elsif selection2 =6then put"Enter your last subtotal here: "..
get subtotal
putskip put"Your subtotal now is $", order6 + subtotal
putskip elsif selection2 =7then put"Enter your last subtotal here: "..
get subtotal
putskip put"Your subtotal now is $", order7 + subtotal
putskip elsif selection2 =0then exit else put"Invalid Selection. Try Again." putskip endif endloop endif endloop
Please specify what version of Turing you are using
4.1.1
Sponsor Sponsor
B-Man 31
Posted: Sun Nov 08, 2009 9:22 am Post subject: Re: Need help on Resturant Menu system
a couple of suggestions, one way to make it better is to have the user click on the items rather than have to select numbers, there is a great tut on Mouse.Where. As well, instead of making the user manually input the previous subtotal you could have your subtotal be:
Turing:
%Selection Code Here
if mouseclickedhere then
subTotal += newItemPrice
endif %So this adds the price of the new item to the subtotal
Thats about what i can say to make it more efficient, if you want to make it look nice, dont use put statements, use Font.Draw. If you don't know how to do something, the Turing Walk Through is unbelievable for helping anyone for understanding new concepts or how they work.
PS: Thanks for naming the bistro after me . My name is Ben as well
junkess
Posted: Sun Nov 08, 2009 1:27 pm Post subject: Re: Need help on Resturant Menu system
B-Man 31 wrote:
a couple of suggestions, one way to make it better is to have the user click on the items rather than have to select numbers, there is a great tut on Mouse.Where. As well, instead of making the user manually input the previous subtotal you could have your subtotal be:
Turing:
%Selection Code Here
if mouseclickedhere then
subTotal += newItemPrice
endif %So this adds the price of the new item to the subtotal
Thats about what i can say to make it more efficient, if you want to make it look nice, dont use put statements, use Font.Draw. If you don't know how to do something, the Turing Walk Through is unbelievable for helping anyone for understanding new concepts or how they work.
PS: Thanks for naming the bistro after me . My name is Ben as well
Thanks but no thanks, Ben. I've already read those instructions and not many of them make sense to me. And also, I was suggested by others that I should keep the input basic, which is really just only manual input. Thanks anyway.
junkess
Posted: Sun Nov 08, 2009 1:32 pm Post subject: Re: Need help on Resturant Menu system
Can somebody still explain to me though what I should do to improve this program? I still am stuck on what to do next. A problem I still have not solved is getting the food menu order prices added up into a subtotal. If you have suggestions, please make them clear and don't suggest me to read the Turing guides. I already have and I have not understood most of what they are saying.
Superskull85
Posted: Sun Nov 08, 2009 2:21 pm Post subject: Re: Need help on Resturant Menu system
Well B-Man 31 has already showed you how to keep track of subtotals without the user entering it themselves:
Turing:
subTotal += newItemPrice
Instead of asking the user for their previous subtotal, just add the item price to the subtotal directly.
If you want to improve your program (make it easier to add stuff in the future) I would look into using arrays and for loops to output menus, and check for input. Code such as this:
Turing:
var order1 :=2.00 var order2 :=2.00 var order3 :=0.75 var order4 :=1.00 var order5 :=1.25 var order6 :=1.25 var order7 :=1.00
Can be represented as an array of real numbers:
Turing:
var order :array1.. 7ofreal:=init(2.00, 0.75, 1.00, 1.25, 1.25, 1.00)
And the users selection can be check by seeing if it is in range of the lower and upper bounds of the array:
Turing:
if selection2 >= 1and selection2 <= upper(order)then
subtotal += order (selection2)%Compute subtotal %Display subtotal else %Tell the user their selection is invalid endif
You can also use arrays to store your menus in, and output them using a for loop:
Turing:
var ExampleMenu :array1.. 3ofstring:=init("Appetizers", "Breakfast", "Lunch") for i :1.. upper(ExampleMenu) putrepeat(" ",5), ExampleMenu (i) endfor
You could also do what B-Man 31 suggested and create clickable menus.
B-Man 31
Posted: Sun Nov 08, 2009 2:26 pm Post subject: RE:Need help on Resturant Menu system
You can also allow the user to order multiple of anything, ask the user how many of set dish, he/she would like to order.
junkess
Posted: Sun Nov 08, 2009 2:58 pm Post subject: Re: Need help on Resturant Menu system
Okay...
First of all, thanks.
Second of all, if I am considering taking B-man's advice and making a click-able menu, how would I do so? I have read the Turing walk through for some extra info but I don't get really what you have to do for Mouse.Where - or whatever it's called. I'm confused.
B-Man 31
Posted: Sun Nov 08, 2009 3:16 pm Post subject: Re: Need help on Resturant Menu system
junkess @ Sun Nov 08, 2009 2:58 pm wrote:
Okay...
First of all, thanks.
Second of all, if I am considering taking B-man's advice and making a click-able menu, how would I do so? I have read the Turing walk through for some extra info but I don't get really what you have to do for Mouse.Where - or whatever it's called. I'm confused.
ok so for the Mouse.Where, there a 3 things you need to find out, the x position of the mouse, the y position and if the button is clicked. thats why the Mouse.Where function has 3 parameters which you have to define
Here is an example to show you how that works:
Turing:
var x, y, button :int
loop Mouse.Where(x, y, button) locate(1, 1) put"X : ", x, " Y : ", y, " Button : ", button
endloop
so you are going to need to know the X and Y coordinates for each of your selections:
Turing:
var x, y, button :int
loop Mouse.Where(x, y, button) drawbox(200, 100, 300, 200) if x > 200and x < 300and y > 100and y < 200and button =1then put"you've made a great selction!" endif endloop
What this means if your mouse is in the box between (200,100) and (300,200) and you've clicked the mouse button then you get the choice. You need to figure out where they are for each selection. The way it is setup this could take a while, if you did use Font.Draw you could have an easier way of figuring out the coordinates because you know one set already. At the moment it would require a lot of tedious work but would improve your program greatly. And if your still having trouble with the subtotal here it is:
Turing:
var x, y, button :int var subTotal :real:=0 var order1 :=2.50
loop Mouse.Where(x, y, button) drawbox(200, 100, 300, 200) if x > 200and x < 300and y > 100and y < 200and button =1then put"you've made a great selction!"
subtotal += order1 %this adds order1 to the subtotal put"your subtotal is now: ", subtotal
endif endloop
Sponsor Sponsor
B-Man 31
Posted: Sun Nov 08, 2009 3:39 pm Post subject: Re: Need help on Resturant Menu system
junkess @ Sun Nov 08, 2009 3:24 pm wrote:
Alright, I came up with another problem. I don't know how to fix this error. Here is the attachment to my latest Menu program. Thanks. Oh and B-man, I'm working on learning the mouse stuff. Thanks for all your help so far.
Replace the current parts witht these:
Turing:
%replace the subtotal variable with this var subtotal :real:=0
%replace the order array with this var order :array1.. 7ofreal:=init(2.00, 0.75, 1.00, 1.25, 1.25, 1.00, 5.45)
%replace the if selection2 = 1 then part with this if selection2 > 1and selection2 < upper(order)then
subtotal += order (selection2) put"Your subtotal now is $", subtotal
else put"Invalid Selection. Try Again." endif
***You were quite close, they were just syntax errors and not coding issues except for the last part (the if statement)
junkess
Posted: Sun Nov 08, 2009 3:47 pm Post subject: Re: Need help on Resturant Menu system
Alright B-man, I'm working on it so thanks. And the example you showed me up there ^ (for the Mouse.Where) ... If I click the button (rectangle), It adds more than just 2.50 because the computer adds more than one order due to my hold time during the time I press the mouse button and get my finger off the mouse button. Is there any way to fix that? I need it so one click just counts as one click, not two per click. Here's the attachment to show you what I mean.
Posted: Sun Nov 08, 2009 3:59 pm Post subject: RE:Need help on Resturant Menu system
After you determine if the button was pressed you could enter a loop and only exit when the button is not pressed:
Turing:
var x, y, button :int %Some code Mouse.Where(x, y, button) if button =1then %Some more code loop Mouse.Where(x, y, button) exitwhen button =0 endloop endif %Some more code
B-Man 31
Posted: Sun Nov 08, 2009 4:00 pm Post subject: Re: Need help on Resturant Menu system
junkess @ Sun Nov 08, 2009 3:47 pm wrote:
Alright B-man, I'm working on it so thanks. And the example you showed me up there ^ (for the Mouse.Where) ... If I click the button (rectangle), It adds more than just 2.50 because the computer adds more than one order due to my hold time during the time I press the mouse button and get my finger off the mouse button. Is there any way to fix that? I need it so one click just counts as one click, not two per click. Here's the attachment to show you what I mean.
Turing:
var x, y, button :int var subtotal :real:=0 var order1 :=2.50 var click :boolean:=false
loop Mouse.Where(x, y, button) drawbox(250, 100, 300, 200, black) if click =falsethen if x > 250and x < 300and y > 100and y < 200and button =1then put"you've made a great selection!"
subtotal += order1 %this adds order1 to the subtotal put"your subtotal is now: ", subtotal
click :=true endif endif if button =0then
click :=false endif endloop
so basically you can only click when click is false so it turns true when you push down but only become false again ones you let go of the button.
junkess
Posted: Sun Nov 08, 2009 4:02 pm Post subject: Re: Need help on Resturant Menu system
This is, again, my latest menu program. This time, I just need to know how to get back to the main menu when I exit out of the Appetizer menu.