Computer Science Canada Turing Array Problem Help! |
Author: | Newspaper [ Sun Apr 22, 2012 12:48 am ] | ||
Post subject: | Turing Array Problem Help! | ||
Hi. I have to make a program that simulates a restaurant for school and it has to print out a bill and i am having trouble getting the selected items to be displayed after the user exits the loop. When i try to display items, it only puts the last selected item and if i try using a for loop to display the items i don't know what range to use. If someone could help me out it would be greatly appreciated!
Thanks! |
Author: | Amarylis [ Sun Apr 22, 2012 7:22 pm ] |
Post subject: | RE:Turing Array Problem Help! |
I'd just like to point out that making two variable names be almost identical is generally seen as "poor form" (amount and Amount arrays) Also, could you please attach the images that you need? I can't quite understand what the problem was, and I can't see it for myself without all the required files (And I'm guessing others may also have a problem) |
Author: | Newspaper [ Sun Apr 22, 2012 7:57 pm ] |
Post subject: | Re: RE:Turing Array Problem Help! |
Amarylis @ Sun Apr 22, 2012 7:22 pm wrote: I'd just like to point out that making two variable names be almost identical is generally seen as "poor form" (amount and Amount arrays)
Also, could you please attach the images that you need? I can't quite understand what the problem was, and I can't see it for myself without all the required files (And I'm guessing others may also have a problem) Sure i'll do that and I wanted amount to stay as amount when I converted it using strint I could change it but it just makes it easier for me. The problem I am facing is to get it to display the selected items in a column after the initial selection process is over. |
Author: | Amarylis [ Sun Apr 22, 2012 8:18 pm ] |
Post subject: | RE:Turing Array Problem Help! |
Personally speaking, I'd just use a dummy check string variable, and just check that variable, as opposed to having a string and integer copy of any value The program is fairly neat, and it's good that you do have a dummy check Okay, so, I just have a question about your code- Why the "total" array? The way I can see it is to just have a "total" real variable, so that way you're keeping track of the total that they've got for all the orders. And as for displaying what they ordered, one way that I can see would be to use a for loop of 1 .. x, and just use that as the array subscripts Last note: I find it unnecessary to have 2 out-of-bounds checks (I'm talking both the Reply ones, where you first have an if statement and then you have a label in your case for it as well) Edit (again): Okay, I know I said that the last one was the last note, but I guess I lied. You might want to consider using Pic.Free as well to free some of those picture variables when they're not needed, and only having 1 picture variable for every picture you need on screen at once (e.g. if you need to have 3 pictures at once on screen, have 3 picture variables, 2 pictures on screen at once, 2 variables, etc) Also, the blue background kinda hurts my eyes when trying to read it, though it may just be me The program is good though |
Author: | Newspaper [ Mon Apr 23, 2012 2:56 pm ] |
Post subject: | Re: RE:Turing Array Problem Help! |
Amarylis @ Sun Apr 22, 2012 8:18 pm wrote: Personally speaking, I'd just use a dummy check string variable, and just check that variable, as opposed to having a string and integer copy of any value
The program is fairly neat, and it's good that you do have a dummy check Okay, so, I just have a question about your code- Why the "total" array? The way I can see it is to just have a "total" real variable, so that way you're keeping track of the total that they've got for all the orders. And as for displaying what they ordered, one way that I can see would be to use a for loop of 1 .. x, and just use that as the array subscripts Last note: I find it unnecessary to have 2 out-of-bounds checks (I'm talking both the Reply ones, where you first have an if statement and then you have a label in your case for it as well) Edit (again): Okay, I know I said that the last one was the last note, but I guess I lied. You might want to consider using Pic.Free as well to free some of those picture variables when they're not needed, and only having 1 picture variable for every picture you need on screen at once (e.g. if you need to have 3 pictures at once on screen, have 3 picture variables, 2 pictures on screen at once, 2 variables, etc) Also, the blue background kinda hurts my eyes when trying to read it, though it may just be me The program is good though Thank you. I have made the suggested changes. The issue of displaying the items still persists how ever. "x" has the value of how ever many times it ran through the loop, lets say 2 times. When I display items in a for loop, it puts the last selected items 2 times in this case. If it ran through the loop 3 times it would put the item 3 times. Sorry if this is a bit troubling haha. I am almost finished the program, just have to figure this problem out quickly as it is due on Wednesday! |
Author: | Amarylis [ Mon Apr 23, 2012 7:05 pm ] |
Post subject: | RE:Turing Array Problem Help! |
try this: [syntax="Turing] for i : 1 .. x put item (i), ": " price (i) end for put "Total was: $", total [/syntax] |
Author: | evildaddy911 [ Mon Apr 23, 2012 8:15 pm ] |
Post subject: | RE:Turing Array Problem Help! |
one thing i suggest, just to make it look nicer, is that you put the picture variables in an array, or just declare them all on the same line i may also suggest looking into records for the amount, Amount, price, item and total arrays. other that that, the program lokks great! |
Author: | Newspaper [ Mon Apr 23, 2012 10:30 pm ] |
Post subject: | Re: RE:Turing Array Problem Help! |
evildaddy911 @ Mon Apr 23, 2012 8:15 pm wrote: one thing i suggest, just to make it look nicer, is that you put the picture variables in an array, or just declare them all on the same line i may also suggest looking into records for the amount, Amount, price, item and total arrays. other that that, the program lokks great!
Hey thanks for the suggestion. I have already implemented the suggested changes . |
Author: | Newspaper [ Mon Apr 23, 2012 10:37 pm ] |
Post subject: | Re: RE:Turing Array Problem Help! |
Amarylis @ Mon Apr 23, 2012 7:05 pm wrote: try this:
[syntax="Turing] for i : 1 .. x put item (i), ": " price (i) end for put "Total was: $", total [/syntax] Hey, that did the trick! Thanks a lot! |
Author: | Amarylis [ Mon Apr 23, 2012 10:50 pm ] |
Post subject: | RE:Turing Array Problem Help! |
No problem, I think you were just getting caught up in using the same array subscript |