Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Need help on Resturant Menu system
Index -> Programming, Turing -> Turing Help
Goto page 1, 2, 3  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
junkess




PostPosted: 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

colour (brightblue)
put "                                   Ben's Bistro  "
colour (grey)
put "--------------------------------------Main Menu---------------------------------"
put skip
put "                           1.  Food Menu"
put "                           2.  Total sales"
put "                           3.  Tips"
put "                           4.  Tax"
put "                           5.  Grand Total"
colour (brightred)
put "                           6.  EXIT"
colour (black)
put skip
put "Select a category. (1,2,3,4,5, or 6)"
get selection
cls
if selection = "1" or selection = "1." then
    colour (darkgrey)
    put "-----------------------------------Food Menu---------------------------------"
    colour (brightgreen)
    put "               Appetizers"
    colour (black)
    put "               Breakfast Menu"
    colour (brightblue)
    put "               Lunch Menu"
    colour (red)
    put "               Dinner Menu"
    colour (11)
    put "               Drinks Menu"
    colour (cyan)
    put "               Dessert Menu"
end if
put skip
colour (black)
put "Select a menu category. (1,2,3,4,5, or 6)"
get selection2
cls
loop
    if selection2 = 1 then
        colour (brightgreen)
        locate (7, 32)
        put "-Appetizers-"
        colour (black)
        locate (9, 32)
        put "1. Nachos............$2.00"
        locate (10, 32)
        put "2. Garlic Bread............$2.00"
        locate (11, 32)
        put "3. Mini-Sandwiches............$0.75"
        locate (12, 32)
        put "4. Fruit Salad............$1.00"
        locate (13, 32)
        put "5. Greek Salad............$1.25"
        locate (14, 32)
        put "6. Caeser Salad............$1.25"
        locate (15, 32)
        put "7. Wedges............$1.00"
        put skip

        loop
            put "Enter your selection number you want to order (Press 0 to exit): " ..
            get selection2
            if selection2 = 1 then
                put "Enter your last subtotal here: " ..
                get subtotal
                put skip
                put "Your subtotal now is $", order1 + subtotal
                put skip
            elsif selection2 = 2 then
                put "Enter your last subtotal here: " ..
                get subtotal
                put skip
                put "Your subtotal now is $", order2 + subtotal
                put skip
            elsif selection2 = 3 then
                put "Enter your last subtotal here: " ..
                get subtotal
                put skip
                put "Your subtotal now is $", order3 + subtotal
                put skip
            elsif selection2 = 4 then
                put "Enter your last subtotal here: " ..
                get subtotal
                put skip
                put "Your subtotal now is $", order4 + subtotal
                put skip
            elsif selection2 = 5 then
                put "Enter your last subtotal here: " ..
                get subtotal
                put skip
                put "Your subtotal now is $", order5 + subtotal
                put skip
            elsif selection2 = 6 then
                put "Enter your last subtotal here: " ..
                get subtotal
                put skip
                put "Your subtotal now is $", order6 + subtotal
                put skip
            elsif selection2 = 7 then
                put "Enter your last subtotal here: " ..
                get subtotal
                put skip
                put "Your subtotal now is $", order7 + subtotal
                put skip
            elsif selection2 = 0 then
                exit
            else
                put "Invalid Selection. Try Again."
                put skip
            end if
        end loop
    end if
end loop


Please specify what version of Turing you are using
4.1.1
Sponsor
Sponsor
Sponsor
sponsor
B-Man 31




PostPosted: 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
end if
%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 Razz . My name is Ben as well
junkess




PostPosted: 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
end if
%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 Razz . 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




PostPosted: 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




PostPosted: 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 : array 1 .. 7 of real := 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 >= 1 and selection2 <= upper (order) then
    subtotal += order (selection2) %Compute subtotal
    %Display subtotal
else
    %Tell the user their selection is invalid
end if

You can also use arrays to store your menus in, and output them using a for loop:

Turing:
var ExampleMenu : array 1 .. 3 of string := init ("Appetizers", "Breakfast", "Lunch")
for i : 1 .. upper (ExampleMenu)
    put repeat (" ", 5), ExampleMenu (i)
end for

You could also do what B-Man 31 suggested and create clickable menus.
B-Man 31




PostPosted: 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




PostPosted: 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. Laughing I'm confused.
B-Man 31




PostPosted: 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. Laughing 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
end loop


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 > 200 and x < 300 and y > 100 and y < 200 and button = 1 then
    put "you've made a great selction!"
end if
end loop


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 > 200 and x < 300 and y > 100 and y < 200 and button = 1 then
        put "you've made a great selction!"
        subtotal += order1 %this adds order1 to the subtotal
        put "your subtotal is now: ", subtotal
    end if
end loop
Sponsor
Sponsor
Sponsor
sponsor
B-Man 31




PostPosted: 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 : array 1 .. 7 of real := 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 > 1 and selection2 < upper (order) then
     subtotal += order (selection2)
     put "Your subtotal now is $", subtotal
else
     put "Invalid Selection. Try Again."
end if



***You were quite close, they were just syntax errors and not coding issues except for the last part (the if statement)
junkess




PostPosted: 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.


Mouse.Where.t
 Description:

Download
 Filename:  Mouse.Where.t
 Filesize:  380 Bytes
 Downloaded:  87 Time(s)

Superskull85




PostPosted: 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 = 1 then
    %Some more code
    loop
        Mouse.Where (x, y, button)
        exit when button = 0
    end loop
end if
%Some more code
B-Man 31




PostPosted: 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 = false then
        if x > 250 and x < 300 and y > 100 and y < 200 and button = 1 then
            put "you've made a great selection!"
            subtotal += order1 %this adds order1 to the subtotal
            put "your subtotal is now: ", subtotal
            click := true
        end if
    end if
    if button = 0 then
        click := false
    end if
end loop


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




PostPosted: 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.


Restuarant Project.t
 Description:

Download
 Filename:  Restuarant Project.t
 Filesize:  2.56 KB
 Downloaded:  100 Time(s)

B-Man 31




PostPosted: Sun Nov 08, 2009 4:09 pm   Post subject: Re: Need help on Resturant Menu system

junkess @ Sun Nov 08, 2009 4:02 pm wrote:
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.


so you need to go from one loop back into another right?

like this

Turing:
loop
   loop
       %some Code
   end loop
end loop


so for each menu you need a quit variable then include this:

Turing:

loop
   loop
      if selection = 8 then
         exit
      end if
   end loop
end loop


This way it will exit the current loop and go back to the other one.
junkess




PostPosted: Sun Nov 08, 2009 4:19 pm   Post subject: Re: Need help on Resturant Menu system

Thanks B-man. That helped me out a lot. Very Happy
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 3  [ 31 Posts ]
Goto page 1, 2, 3  Next
Jump to:   


Style:  
Search: