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

Username:   Password: 
 RegisterRegister   
 Different Questions in True/False Quiz (Parallel Get)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Rom




PostPosted: Tue Jan 16, 2007 11:12 am   Post subject: Different Questions in True/False Quiz (Parallel Get)

Hello everyone,

I was wondering how to get different questions in parralelget

Here's my code:

code:
var x : int

put "1. A standard guitar has 5 strings."

loop
x := parallelget
if x = 88 then
locate(2,1)
put "True"
Music.PlayFile ("T0386900.wav")
locate(3,1)
put "Incorrect!"
delay (200)
Music.PlayFile ("I0091600.wav")
end if

if x = 248 then
locate(2,1)
put "False"
Music.PlayFile ("F0023700.wav")
locate(3,1)
put "Correct!"
delay (200)
Music.PlayFile ("C0659000.wav")
end if


end loop



How do I add more questions?

Thanks alot.
Sponsor
Sponsor
Sponsor
sponsor
aznrex




PostPosted: Tue Jan 16, 2007 10:15 pm   Post subject: Re: Different Questions in True/False Quiz (Parallel Get)

use
if
elsif
end if
Rom




PostPosted: Tue Jan 16, 2007 11:09 pm   Post subject: Re: Different Questions in True/False Quiz (Parallel Get)

aznrex @ Tue Jan 16, 2007 10:15 pm wrote:
use
if
elsif
end if

Hello,

I tried it but it won't work because the loop of parallelget gets on one place and doesn't move to the other question.
CodeMonkey2000




PostPosted: Wed Jan 17, 2007 12:16 am   Post subject: RE:Different Questions in True/False Quiz (Parallel Get)

Why are you usin parallel get? isn't that for peripherals?
Rom




PostPosted: Wed Jan 17, 2007 7:45 am   Post subject: Re: Different Questions in True/False Quiz (Parallel Get)

I need it for a project.

Anyone knows?
Rom




PostPosted: Wed Jan 17, 2007 8:17 pm   Post subject: RE:Different Questions in True/False Quiz (Parallel Get)

Anyone? Sad

Or is there a different way to add more questions?

Thanks.
Rom




PostPosted: Thu Jan 18, 2007 11:34 am   Post subject: RE:Different Questions in True/False Quiz (Parallel Get)

Here's my new code but it still doesn't work

code:

process main
var counter : int

put "1. A standard guitar has 5 strings."
counter := 1
locate(4,1)
put "2. Say TRUE."
counter := 2
end main

process check
var x : int
var x2 : int
loop
x := parallelget
x2 := parallelget
if x = 88 then
locate(2,1)
put "True"
Music.PlayFile ("T0386900.wav")
locate(3,1)
put "Incorrect!"
delay (200)
Music.PlayFile ("I0091600.wav")
elsif x = 248 then
locate(2,1)
put "False"
Music.PlayFile ("F0023700.wav")
locate(3,1)
put "Correct!"
delay (200)
Music.PlayFile ("C0659000.wav")
end if


if x2 = 248 then
locate(5,1)
put "True"
Music.PlayFile ("T0386900.wav")
locate(6,1)
put "Incorrect!"
delay (200)
Music.PlayFile ("I0091600.wav")
elsif x2 = 88 then
locate(5,1)
put "False"
Music.PlayFile ("F0023700.wav")
locate(6,1)
put "Correct!"
delay (200)
Music.PlayFile ("C0659000.wav")
end if

end loop
end check

fork check
fork main


Anyone? Sad
vertozia




PostPosted: Thu Jan 18, 2007 3:29 pm   Post subject: RE:Different Questions in True/False Quiz (Parallel Get)

umm thats strange, id id my multiple choice questions in a different way using if, i dont know why you used procedures, that makes it much harder, even for score keeping. another alternative is labels, but you cant keep a ascore either.

look at this:

code:
setscreen ("graphics:690,650")
colorback (black)
cls
color (brightgreen)

var sel1:int

loop
    cls

    color (yellow)
    put "       MULTIPLE CHOICES       "
    put skip
    color (brightgreen)
    put "    Question 1 - What is the area"
    put "    of a square with a lenght of      4 cm"
    put "    7cm and a width of 4cm?"

    put skip
    Draw.Box (350, 600, 543, 550, white)
    put "                                                      7 cm"
    color (brightred)
    put "   1) 28cm"
    put "   2) 56m "
    put "   3) 17cm"
    put "   4) 17m"
    put skip
    color (brightpurple)
    put "Answer:" ..
    color (77)
    get sel1

    if sel1 = 1 then
        put "YOU ARE CORRECT!"
        delay (500)
    elsif sel1 = 2 or sel1 = 3 or sel1 = 4 then
        put "YOU ARE INCORRECT!"
        delay (500)
    else
        put "PLEASE MAKE A CHOICE"
        delay (500)

    end if
    exit when sel1 = 1
end loop
delay (300)
Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Thu Jan 18, 2007 4:25 pm   Post subject: Re: Different Questions in True/False Quiz (Parallel Get)

why not use functions that return a boolean value?

Turing:

fcn correct (true_answer, given_answer : string) : boolean
    result true_answer = given_answer
end correct

procedure ask_question (question, answer : string, allowed_tries : int)
    var guess : string
    for i : 1 .. allowed_tries
        put question
        get guess :*
        if correct (answer, guess) then
            %do whatever
        end if
    end for
    put "Sorry, out of tries"
end ask_question


Very Happy
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  [ 9 Posts ]
Jump to:   


Style:  
Search: