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

Username:   Password: 
 RegisterRegister   
 A Quick Question About My Quiz
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
qmanjr5




PostPosted: Wed Mar 24, 2010 10:56 am   Post subject: A Quick Question About My Quiz

Do I have to set the variable for the answers at the beginning, even though I'm setting what the correct answer is, in the main code?

Turing:

%Miscellanius
import GUI
Draw.FillBox (0, 0, maxx, maxy, black)
Text.Colour (brightgreen)
Text.ColourBack (black)

%Variables and values
var score : int := 0
var answer1 : string := "3"
var answer2 : string := "33000000"
var answer3 : string := "Barack Obama"

%Procedures and processes
process applause
    Music.PlayFile ("applause.MP3")
end applause

process boo
    Music.PlayFile ("boo.MP3")
end boo
process thinking

    Music.PlayFile ("thinking.MP3")
end thinking

procedure correct
    fork applause
    cls
    score += 1
    put "YAY! :) You got it right. Your score has been increased by 1"
    put "Press any key to continue"
    Input.Pause
    cls
end correct

procedure incorrect
    fork boo
    cls
    score -= 1
    put "Oh no :( You got it wrong. Your score has been decreased by 1"
    put "Press any key to continue"
    Input.Pause
    cls
end incorrect

procedure currentscore
    put "Your current score is ", score, ". Next question."
    put "Press any key to continue"
    Input.Pause
end currentscore

procedure finished
    put "CONGRATULATIONS! You've finished. Your final score was ", score, ". Good job."
end finished

%Maintest
procedure Maintest
    cls
    put "Hello, welcome to my quiz."
    put "First question"
    put "What is 1+1? (ex. 3 [No letters])"
    fork thinking
    get answer1 : *
    if answer1 = "2" then
        correct
    else
        incorrect
    end if
    currentscore

    put "Question two."
    put "What is the population of Canada? (Ex. 1000000 [No comma's, or letters])"
    fork thinking
    get answer2 : *
    if answer2 = "33000000" then
        correct
    else
        incorrect
    end if
    currentscore

    put "Question 3"
    put "Who is the president of the united states of america? (Case Sensitive [Full Name])"
    fork thinking
    get answer3 : *
    if answer3 = "Barack Obama" then
        correct
    else
        incorrect
    end if
    currentscore
end Maintest

%More
procedure start
    cls
    put "Press any key to start"
    Input.Pause
    Maintest
end start

procedure exittest
    quit
end exittest

procedure Instructions
    put "Insert instructions here"
end Instructions

%Menu
put "What do you want to do?"
var button1 : int := GUI.CreateButton (25, 25, 0, "Start the quiz", start)
var button2 : int := GUI.CreateButton (125, 25, 0, "Exit the game", exittest)
var button3 : int := GUI.CreateButton (225, 25, 0, "Instructions", Instructions)
loop
    exit when GUI.ProcessEvent
end loop
Sponsor
Sponsor
Sponsor
sponsor
USEC_OFFICER




PostPosted: Wed Mar 24, 2010 11:39 am   Post subject: RE:A Quick Question About My Quiz

No, because you are overwriting the variables anyway, so what's the point?
andrew.




PostPosted: Wed Mar 24, 2010 1:48 pm   Post subject: RE:A Quick Question About My Quiz

You don't except for the score integer. The reason for this is because you used "score += 1" and to do this, you must have an initial value to add 1 to.
USEC_OFFICER




PostPosted: Wed Mar 24, 2010 4:00 pm   Post subject: RE:A Quick Question About My Quiz

Yah, he already knows that.
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 1  [ 4 Posts ]
Jump to:   


Style:  
Search: