Computer Science Canada What's wrong with my code? |
Author: | P-Nut311 [ Wed Dec 15, 2004 8:40 pm ] | ||
Post subject: | What's wrong with my code? | ||
I'm telling my program to randomize between 2 different questions, but it only randomizes the first one over and over again. How do I make it so that the program randomizes these two questions, BUT DOESN'T REPEAT THEM. Example: Question 2 can appear before question 1, but once question 2 is answered correctly, it will not appear again until the user manually starts the game over. Heres the randomize part of the code:
|
Author: | Tony [ Wed Dec 15, 2004 10:33 pm ] | ||
Post subject: | |||
haven't you posted that before? ![]() Quote: randint (history, 1, 2) After you randomly picked a number (out of all possible rights and wrongs btw), you also forgot to check it against the list of wrong outputs. So
|
Author: | P-Nut311 [ Wed Dec 15, 2004 11:03 pm ] |
Post subject: | |
What is "try_again()"? Can you give me an example of code that randomizes, lets say, 5 questions of type string, but doesn't repeat the questions? I'm making a 'game show' type of game, so questions are to be randomized, but only appear in the game once. |
Author: | Tony [ Wed Dec 15, 2004 11:22 pm ] |
Post subject: | |
random numbers without repetition |
Author: | P-Nut311 [ Thu Dec 16, 2004 4:40 pm ] |
Post subject: | |
ok... My teacher says I need an array in order to randomize 'strings'. How do I set up an array and randomize the strings at the same time. Would my code go like this... ? loop randomize var history : array 1..5 of string [code continues] History is of type 'string', so from what my teacher told me, strings cannot be randomized with the 'randint' command. But he said to put some randomize command before the array command, so that the questions will be randomized. How do I do this? Can anyone give me an example? |
Author: | Tony [ Thu Dec 16, 2004 5:12 pm ] |
Post subject: | |
tony wrote: |
Author: | P-Nut311 [ Thu Dec 16, 2004 5:21 pm ] |
Post subject: | |
"I wrote up this little piece of code for a question on this exact topic." Don't tell me... I... nah.... ![]() |
Author: | P-Nut311 [ Thu Dec 16, 2004 5:53 pm ] |
Post subject: | |
so, would my code go something like this...? var hold : string var question : array 1..5 of string for i : 1..5 question (i) := i end for for i : 1..5 hold := randint (question, 1, 5) put question (hold) question (hold) := question (i) end for ----- What does 'i' do? How do I make it so that whatever question the program chooses, it will put it in a special font using the 'Font.Draw' command? Would I need to create a counter? I want the game to randomize the first 5 questions, which are beginner questions. After the user passes the 5th question, then the program will randomize questions 6 - 10, which are moderate questions. How would I do that? With a counter? |
Author: | Tony [ Thu Dec 16, 2004 6:06 pm ] |
Post subject: | |
yes |
Author: | P-Nut311 [ Thu Dec 16, 2004 6:32 pm ] |
Post subject: | |
Can u explain what each line of code does? I'm confused. ![]() |
Author: | P-Nut311 [ Thu Dec 16, 2004 11:27 pm ] | ||
Post subject: | |||
Ok, I think I'm getting this now. I got the code to work, but it outputs intergers only. What must I do to the code to make the program output a random question (word problem)? The array also never stops, is it because it has a loop? Ok... let's say I want the variable 'historyquestion1' to display "Who made Turing?" on the screen. Question 2 will ask "When was Turing made?". Question 3 will ask "dgsa?" and so on.... how do I make the program display these questions?
|