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

Username:   Password: 
 RegisterRegister   
 My Millionaire game... Completed... Help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
MossyMossy




PostPosted: Wed Apr 07, 2010 9:12 am   Post subject: My Millionaire game... Completed... Help

Here is my completed code. For my millionaire game, including images + answers.


All that is missing, Is my lifelines...


I have my code example. But I cannot find a way to input into the actual code..




Turing:


var choice:array 1..4 of string
choice[1] = "a"
choice[2] = "b"
choice[3] = "c"
choice[4] = "d"

var answerIndex:int := 2 % the answer is "b"
     %// ofcourse all of the above should be loaded from a datafile
 


%so we have an array full of answers and we know that 2nd one is correct.. aka choice(answerIndex)

%now lets say we want to let the user pick just 2 of the above (after using 50-50)


var wrongChoices:array 1..3 of int %all the wrong answers
var myChoices:array 1..2 of int %1 correct 1 wrong

var counter:int := 1 %just follow along

for i:1..4
     if i not= answerIndex then
          wrongChoices(counter) := i
          counter += 1
     end if
end for

%now wrongChoices has all of the indexes but answerIndex
%so

myChoice(1) := answerIndex
myChoices(2) := wrongChoices(Rand.Int(1,3))

%myChoice(1) is the correct answer's index
%myChoice(2) is a random incorrect answer's index
 


%and now you're ready! let the user pick between answer # myChoice(1) or myChoice(2).. you might want to keep track of the other two answers that will be crossed out, though those can be figured out since they are not in the list.



loop
     put "pick an answer"
     get myAnswer
     if myAnswer = myChoice(1) or myAnswer = myChoice(2) then
          %check if myAnswer = answerIndex, if so - user wins
           exit
     else
           put "you can't pick that"
     end if
end loop
 






Can you please help, Input this to my actual millionaire game.



Millionaire.zip
 Description:
My Millionaire game...

Download
 Filename:  Millionaire.zip
 Filesize:  445.06 KB
 Downloaded:  88 Time(s)

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  [ 1 Posts ]
Jump to:   


Style:  
Search: