
-----------------------------------
qmanjr5
Tue May 18, 2010 10:34 am

My Quiz
-----------------------------------
Here it is, some of my quiz that I made a few months ago and haven't gotten around to finishing or posting on here


%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 

-----------------------------------
chrisbrown
Tue May 18, 2010 10:47 am

RE:My Quiz
-----------------------------------
It's nice to see some use of procedures rather than a hundreds of lines of mostly cut & paste, but since I see you appreciate the need for good code organization:
[code]var answer1 : string :=  "3"
var answer2 : string := "33000000"
var answer3 : string := "Barack Obama"[/code]
Use arrays for both questions and answers, and a for loop in Maintest to improve further (if you plan on doing so).

-----------------------------------
SNIPERDUDE
Tue May 18, 2010 1:17 pm

RE:My Quiz
-----------------------------------
Arrays in for loops can significantly decrease code length.
I think this is the first time I've seen someone post a quiz programme with procedures here (at least the Turing forum, I don't really read too much of the rest)

-----------------------------------
qmanjr5
Thu May 20, 2010 10:29 am

Re: RE:My Quiz
-----------------------------------
It's nice to see some use of procedures rather than a hundreds of lines of mostly cut & paste, but since I see you appreciate the need for good code organization:


Yeah, I can't stand it if I can't organize my code somewhat :P
And I've yet to learn arrays, I'll go do that right now.

-----------------------------------
qmanjr5
Thu May 20, 2010 10:30 am

Re: RE:My Quiz
-----------------------------------
Arrays in for loops can significantly decrease code length.
I think this is the first time I've seen someone post a quiz programme with procedures here (at least the Turing forum, I don't really read too much of the rest)

I've yet to learn a language where I didn't create a quiz, the first thing I make.

-----------------------------------
qmanjr5
Thu May 20, 2010 10:42 am

Re: RE:My Quiz
-----------------------------------
It's nice to see some use of procedures rather than a hundreds of lines of mostly cut & paste, but since I see you appreciate the need for good code organization:

I read the arrays tutorial...

I have a headache now  :cry:
