Random questions help
Author |
Message |
tehguy44
|
Posted: Sun Jun 14, 2009 11:52 am Post subject: Random questions help |
|
|
What is it you are trying to achieve?
I am trying to create a quiz game that the questions randomize every time the quiz starts.
What is the problem you are having?
The questions are repeating themselves withing my program because of my randint
Describe what you have tried to solve this problem
I have tried to make a counter after each question and then use an if statement to stop the questions from being repeated, but I am not exactly sure how to make it function how I would like.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
This is the code from my questions, I only have two of my six questions completed, so there is not too much code.
Turing: |
loop
randomize
randint (question, 1, 2)
if question = 1 then
q1c := q1c + 1
put "What is the name of the city the David Lightman lived in?"
put ""
put "A) New York"
put "B) Seattle"
put "C) Chicago"
put "D) Toronto"
get qa1
if qa1 = "B" or qa1 = "b"
then
put "You are right good job"
else
put "Oh sorry you are wrong."
end if
end if
if question = 2 then
q2c := q2c + 1
put "What is the name of the computer that David hacked into?"
put ""
put "A) W.O.P.R."
put "B) N.R.S.C."
put "C) NORAD"
put "D) B.O.B."
get qa2
if qa2 = "A" or qa2 = "a"
then
put "Great! You are right!"
else
put "Better luck next time, you are wrong!"
end if
end if
end loop
|
Please specify what version of Turing you are using
I am using 4.1.1
Oh and yes this quiz is about the movie war games, my computers teacher is in love with that movie, haha. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Nai
|
Posted: Sun Jun 14, 2009 12:07 pm Post subject: RE:Random questions help |
|
|
Try creating a variable that changes when the question has already been asked. Put in the if statement that if the variable=not asked then the question can be asked. Then change the variable to say that the question has been asked after you're done asking it. Hope this helps! |
|
|
|
|
|
apomb
|
Posted: Sun Jun 14, 2009 12:14 pm Post subject: RE:Random questions help |
|
|
Well first of all, use Rand.Int not randint and also, do what Nai said and keep track of the questions already asked. |
|
|
|
|
|
tehguy44
|
Posted: Sun Jun 14, 2009 12:18 pm Post subject: Re: Random questions help |
|
|
Thank you Nai, that was something I was thinking might work to solve my problem but I was really certain. I appreciate the help |
|
|
|
|
|
|
|