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

Username:   Password: 
 RegisterRegister   
 Need sum quick help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
bullets




PostPosted: Wed Jun 08, 2005 12:29 pm   Post subject: Need sum quick help

Ok first thing What grade are you guys in that are doing games in turing??

anyways moving along to what i need help with i need to make this quiz thing and i know theres an easier way to do it but i just cant sem to get it (this needs to be for 10 questions) heres what i wrote up for 2 questions quickly

var a1, a2, a3, a4, a5, a6, a7, a8, a9, a0, total : int
var guess, guess1 , guess2 , guess3 : int := 0

locate (2, 25)
put "Quiz on Ironclads"
loop
guess := guess + 1
locate (4, 1)
put " Question 1: Is blah blah blah blah"
put " 1. "
put " 2. "
put " 3. "
put " 4. "
put "Please enter the correct number"
get a1
if a1 = 1 then
cls
locate (10, 23)
put "Correct, Now for the Next Question"
elsif a1 >= 2 then
put "Incorrect"
end if
if guess = 3 and a1 >= 2 then
put "NiCe TrY"
end if
exit when a1 = 1 or guess = 3
end loop
delay (1000)
cls

locate (2, 25)
put "Quiz on Ironclads"
loop
guess1 := guess1 + 1
locate (4, 1)
put " Question 2: Is blah blah blah blah"
put " 1. "
put " 2. "
put " 3. "
put " 4. "
put "Please enter the correct number"
get a2
if a2 = 2 then
cls
locate (10, 23)
put "Correct, Now for the Next Question"
elsif a2 >= 2 then
put "Incorrect"
end if
if guess1 = 3
then put "NiCe TrY"
end if
exit when a2 = 1 or guess1 = 3
end loop
delay (1000)
cls

also what would i type to make it so any key that is pressed that it would go back to the main page

another thing (haha sry Very Happy ) is it possible to load up something, Like say on the menu the person selects the quiz so when that button is pressed i want Turing to load Quiz.t as the main screen
Sponsor
Sponsor
Sponsor
sponsor
jamonathin




PostPosted: Wed Jun 08, 2005 1:00 pm   Post subject: (No subject)

Array's are very useful. Use them for your program (like I did).

Now for your loading question. Yes it is very possible. All you have to do is save the 1. questions, 2. correct answers, and 3. possible answers. Worry about one thing at a time tho. You can look that stuff up in the Tutorials, and if you cannot find it, look for the sticky on Turing Walkthrough.

Anyways, take a look at this.
code:
%This is what the user puts in.
var input : int
%These are all 10 questions.  They are in an array.
var question : array 1 .. 10 of string := init ("Question 1", "Question 2", "Question 3", "Question 4", "Question 5", "Question 6", "Question 7", "Question 8", "Question 9", "Question 10")
%These are the answers to the corresponding questions. These are the right answers for each question. *Number*
var answer : array 1 .. 10 of int := init (1, 2, 3, 4, 1, 2, 3, 4, 1, 2)
%This is the text for each question.
%  *1 .. 10* is for all 10 questions
%  *1 .. 4* is for the 4 options.
var answers : array 1 .. 10, 1 .. 4 of string
%This is just filling in the empty spots, not necessary for the program.
% You will need to do everything individually
for q : 1 .. 10
    for a : 1 .. 4
        answers (q, a) := intstr (Rand.Int (1, maxint)) %This just generates a random number for each answer
    end for
end for
% You will have to do every possible answer individually.  Such as this.
%Question 1:
answers (1, 1) := "Jamonathin"
answers (1, 2) := "Fart"
answers (1, 3) := "Pizza"
answers (1, 4) := "Cheeseburger"
%Question 2:
answers (2, 1) := "Cheeseburger"
answers (2, 2) := "Jamonathin"
answers (2, 3) := "Fart"
answers (2, 4) := "Pizza"
%Question 7:
answers (7, 1) := "WRONG"
answers (7, 2) := "WRONG"
answers (7, 3) := "RIGHT ANSWER"
answers (7, 4) := "WRONG"

for i : 1 .. upper (question) %Max amount of questions
    for q : 1 .. 3 % For 3 guesses.
        cls
        locate (2, 25)
        put "Quiz on Ironclads"
        put question (i)
        put " 1. ", answers (i, 1)
        put " 2. ", answers (i, 2)
        put " 3. ", answers (i, 3)
        put " 4. ", answers (i, 4)
        delay (500)
        put "Please enter the correct number"
        get input
        if input = answer (i) then
            cls
            locate (10, 23)
            put "Correct! Now for the Next Question"
            delay (1000)
            exit %E xiting for loop
        else
            cls
            locate (10, 23)
            put "Incorrect"
            delay (1000)
        end if
    end for
end for
bullets




PostPosted: Wed Jun 08, 2005 4:03 pm   Post subject: (No subject)

what does this do?? array 1 .. 10 of int := init nvr seen this used before

also this

"answers (q, a) := intstr (Rand.Int (1, maxint)) %This just generates a random number for each answer" dont understand the point of this


thanks for the help we didnt learn arrays n all that jazz in my class unfortunately[/b]
Cervantes




PostPosted: Wed Jun 08, 2005 4:36 pm   Post subject: (No subject)

Well, if you've never seen it before, a good thing to do is look it up in the Turing Help file. Surprisingly, it's helpful!
Learning keywords such as init and round and Math.Distance (etc.) from the help file is fine, but learning concepts such as variables, arrays, classes, etc. is more difficult. That's why we've got tutorials. Check for the arrays tutorial (we've actually got two). There's a link to it in the Turing Walkthrough (at the top).
Cheers!
bullets




PostPosted: Wed Jun 08, 2005 5:12 pm   Post subject: (No subject)

help file from turing?? doesnt work for us so i dont know any of the keywords and or what they do
Cervantes




PostPosted: Wed Jun 08, 2005 5:19 pm   Post subject: (No subject)

Are you sure? Hitting F10 while in Turing does nothing? Clicking Help -> Turing Reference does nothing/it does not exist? What version of turing do you have?

In any case, init is used to initialize the elements of an array. If you have an array from 1 to 5 of integers, and you want to assign them values without doing each one individually, you can do it like this:
code:

var myArray : array 1 .. 5 of int := init (3, 9, -96, 32, 0)

Note that if you use init, you have to have as many parameters as there are elements of that array.
bullets




PostPosted: Wed Jun 08, 2005 5:22 pm   Post subject: (No subject)

When i go to the help menu the first 3 options are grey and whn i hit f10 nothing happens using 4.0
jamonathin




PostPosted: Thu Jun 09, 2005 6:00 am   Post subject: (No subject)

Well then stick to the Tutorials, cuz they're pretty much, just as good, and in some cases beter.
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: