Computer Science Canada

[source] almost done "Who wants to be a milionaire"

Author:  DanShadow [ Tue Jan 20, 2004 5:48 pm ]
Post subject:  [source] almost done "Who wants to be a milionaire"

Here is a start to "Who Wants to be a Millionaire":
code:

var questions:array 1..10 of string
var choice1,choice2,choice3,choice4,real_answer:array 1..10 of string
var money_for_question:array 1..10 of int
var lifelinez:array 1..3 of string
var lifeline_used:array 1..3 of boolean
var input:string:=""
var money,num:int:=0
lifelinez(1):="Ask the Audience"
lifelinez(2):="Fifty Fifty"
lifelinez(3):="Phone a Friend"
for i:1..3
lifeline_used(i):=false
end for

procedure lifelines
put "Lifelines: "..
for i:1..3
put lifelinez", "..
end for
put ""
put "Which lifeline do you wish to use: "..
get input:*
if input="Ask the Audience" and lifeline_used(1)=false then
ask_the_audience
elsif input="Fifty Fifty" and lifeline_used(2)=false then
fifty_fifty
elsif input="Phone a Friend" and lifeline_used(3)=false then
phone_a_friend
else
put "That is not a lifeline, or it has already been used..."
end if
num:=num-1
end lifelines
procedure ask_the_audience
%Ask the Audience procedure
lifeline_used(1):=true
end ask_the_audience
procedure fifty_fifty
%50/50 procedure
lifeline_used(2):=true
end fifty_fifty
procedure phone_a_friend
%Phone a Friend procedure
lifeline_used(3):=true
end phone_a_friend

put "Welcome to Who Wants to be a Millionaire!!"
put "HINT: Type 'lifeline' to use a lifeline."
put ""
loop
num:=num+1
put "Question: " question (num)
put "a) green ",choice1(num)
put "b) white ",choice2(num)
put "c) blue ",choice3(num)
put "d) brown",choice4(num)
put "Answer: "..
get anwer
if answer = real_answer (num) then
money:= money+money_for_question(num)
elsif answer = "lifeline" then
lifelines
elsif answer not = real_answer(num) then
put "Sorry buddy, you LOSE!"
exit
end if
exit when num>=10
end loop
if num=10 then
put "Congratulations! You won ",money," dollars!!"
else
put "You have lost everything...now go home and cry yourself to sleep!"
end if

Just change the array max values to the number of questions you have...and create the questions, choices, and real answer. Also, create what happens in the lifelines, and how much money you'll get per question. This is a good start to "Who Wants to be a Millionaire!", and i've already answered this too many people, so if you dont understand this, PM me. I wont do your whole project for you, but this is pretty much how it goes. No more having like dozens of people adding me to their msn seeking help.. gr Evil or Very Mad
Warning!
Seeing as this is being posted on CompSci...multiple people may be using it as their project..so, if your teacher finds like a dozen of you out there with the same project, it is NOT in any way my fault!

Enjoy the code, and put it to good use!s
[Edit] Fixed a couple bugs...should work now

Author:  kalin [ Wed Jan 21, 2004 3:30 pm ]
Post subject: 

Hey!! What about me??


: