Computer Science Canada Need Help With My Turing Quiz Please |
Author: | Gildemore [ Wed Jan 21, 2009 1:10 am ] | ||||
Post subject: | Need Help With My Turing Quiz Please | ||||
Im pretty new to turing and this is for my grade 10 project. I decided to make a small math quiz game thing (some of the answers to the questions are wrong cause i havn't edited them yet) anyways so everything works (i hope) except for the elsif's that i have. cause at the beggining you have a choice of either 1,2,3 or 4 which are difficulties so i used elsif for each one but i guess they are too far apart and didnt connect or whatever. please look at my code and help? thank you all
Mod Edit: Remember to use syntax tags! Thanks
|
Author: | Gildemore [ Wed Jan 21, 2009 1:40 am ] | ||||
Post subject: | Re: Need Help With My Turing Quiz Please | ||||
okay i fixed that problem but now after it asks the first question of any difficulty it auto skips to like the third or fourth question and the mark you get is always 0 so im not sure whats going on any help? heres the new code
Mod Edit: Syntax tags
|
Author: | Zren [ Wed Jan 21, 2009 3:50 am ] | ||||||
Post subject: | Re: Need Help With My Turing Quiz Please | ||||||
Please wrap all your code in: [ code ] ... [ /code ] As for you program, it's all in the variable declaration. A char data type only represents 1 character. Now I believe they're only 1 byte in size. So you organized a,b,c,d,e in memory all together.
Now when you asked for A with get a, which returned a string. For a string, each letter is 2 bytes in size (I think, at least it proves this theory). So what do we get? If we enter the answer to Diff level 1 first question "3+29", which has the answer "32". The answer would contain 2 letters, however since it's a string, it would be 4 bytes in size. So here's the problem. The command get sorta has a memory, so if it doesn't get rid of all the data the user inputs, it will hold onto it for each proceeding get command until it's empty. Like so...
So when we finally get to Question E, we have to get more user input to continue.
This here is also the problem when you have the 0 out of 5 at the end. Since it's always looking at the wrong part of memory. The way to fix this is to just declare a,b,c,d,e as :string. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Another thing. x := x What the hell is this? It's kinda useless. Your telling a variable to stay the same. So why put it in there. If you must, comment it and put "//Score stays the same" or something. If your teacher told you to do this...uhg. Another thing, you don't really need to embed all the if statements. Unless it's not suppose to ask question 2 unless it's question 1 is done...Okay I see where you went with this, but it's just alot easier to put it like so: get a if a = right score +1 end if get b ...etc. |