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

Username:   Password: 
 RegisterRegister   
 Millionaire help...... again (exiting, and lifelines)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
sofa_king




PostPosted: Tue Jun 08, 2004 8:25 pm   Post subject: Millionaire help...... again (exiting, and lifelines)

yikes time sure flies. my program is due friday the latest Shocked . damn exams and stuff prevented me from working.

Anyways i havent got much far from before but i do have some problems. I will just point them out instead of blabbing:

-Im having a bit of troubles with inputting lifelines, ont noe where to start. ince there are three, here i go, you dont have to explain this if you dont want to because i havent started it and it be pretty cheap.
- phoning a friend- basically what i want is that when a person chooses this, the computer will be the friend. the chance of the computer getting it right in harder questions is less.
- 50/50- basically what im gessing, is that i'll use colorback to blend witht he background.
-asking audience- same theory as phoning a freind but i mite hav trouble adding the percentage of what audience thinks.

ive decided to hardcode all the questions since i am still not sure how to upload txt files and im not in the mood to learn something new. I'' post questions up to a 1000 so it doesnt take up the whole page. BTW im gonna add more questions to each set eventually- so if you have any concerns about that then thx

code:

colorback (black)
cls

var reply : string (1) %variable to use with getch command
var answer : int %the answer that the user inputs
var right_answer : int %the right answer
var chance : int := 3 %number of chances the user gets
var restart:string


color (white)
locate (11, 27)
put "Welcome to the Gameshow:"
locate (12, 25)
put "WHO WANTS TO BE A MILLIONAIRE!"

locate (25, 1)
put "Press any key to Start Game:" ..
getch (reply)

procedure right
    if answer = right_answer then
        put "YOU ARE RIGHT!!!"
        put "Press any key to go to next question" ..
        getch (reply)
    elsif chance = 0 then
        put "You lose the game, press any key to restart:" ..
        getch (reply)
    else
        chance := chance - 1
        put "Wrong, you have ", chance, " chances left"
        put "Press any key to go to next question" ..
        getch (reply)
    end if
end right

procedure onehundred %$100 question
    cls
    put "For $100:"
    put ""
    put "What is the Capital of Canada?"
    put "1)Quebec"
    put "2)Ontario"
    put "3)Ottawa"
    put "4)Toronto"

    put "What will you choose?" ..
    get answer
    put ""

    right_answer := 3
    right
end onehundred

procedure twohundred %$200 question
    cls
    put "For $200:"
    put ""
    put "What are the three forms of matter?"
    put "1)Solid, Liquid and Gas"
    put "2)Solid, Liquid and Air"
    put "3)Ice, Water and Steam"
    put "4)Solid, Liquid and plasma"

    put "What will you choose?" ..
    get answer
    put ""

    right_answer := 1
    right
end twohundred

procedure threehundred %$300 dollar question
    cls
    put "For $300:"
    put ""
    put "What is the second element in the periodic table"
    put "1)Hydrogen"
    put "2)Helium"
    put "3)Oxygen"
    put "4)Nitrogen"

    put "What will you choose?" ..
    get answer
    put ""

    right_answer := 2
    right
end threehundred

procedure fivehundred %$500 dollar question
    cls
    put "For $500:"
    put ""
    put "What year did confederation for Canada happen?"
    put "1)1798"
    put "2)1852"
    put "3)1867"
    put "4)1901"

    put "What will you choose?" ..
    get answer
    put ""

    right_answer := 3
    right
end fivehundred

onehundred
twohundred
threehundred
fivehundred
Sponsor
Sponsor
Sponsor
sponsor
sofa_king




PostPosted: Wed Jun 09, 2004 5:05 pm   Post subject: (No subject)

Well no help Confused . dont worry, im starting to get most of them. I have got the phonecall lifeline done, have some bugs on the 50/50 lifeline, and im going to start the audience (i mite need some help in this later).

Also a problem that i still have is that i still cant exit when the person gets the question worng >.<, ive been trying to get this for a while now. Other than that, i think im pretty safe for compooper skience..... errrr atleast to get a passing mark.

heres my buggy v2 so far. DONT use 50/50, its really messed up, trying to work it out.

code:
colorback (black)
cls

var reply : string (1) %variable to use with getch command
var answer : int %the answer that the user inputs
var right_answer : int %the right answer
var restart : string %choice if the user wants to restart
var choicea, choiceb, choicec, choiced, question : string %options when choosing rght answer
var elim1, elim2 : int %the two options that get eliminated in the lifeline 50/50
var value, valran : int% value of the question

%the intro
color (white)
locate (11, 27)
put "Welcome to the Gameshow:"
locate (12, 25)
put "WHO WANTS TO BE A MILLIONAIRE!"

locate (25, 1)
put "Press any key to Start Game:" ..
getch (reply)

procedure fiftyfifty %50/50 lifeline
    loop
        randint (elim1, 1, 4)
        randint (elim2, 1, 4)
        if elim1 = right_answer or elim2 = right_answer then
            put ""
        elsif elim1 = elim2 then
            put ""
        else
            exit
        end if
    end loop

    if elim1 = 1 or elim2 = 1 then
        drawfillbox (1, 50, maxx div 2, 100, black)
    elsif elim1 = 2 or elim2 = 2 then
        drawfillbox (maxx div 2, 50, maxx, 100, black) %second question
    elsif elim1 = 3 or elim2 = 3 then
        drawfillbox (1, 1, maxx div 2, 50, black) %third question
    elsif elim1 = 4 or elim2 = 4 then
        drawfillbox (maxx div 2, 1, maxx, 50, black) %fourth
    end if
    get answer
end fiftyfifty

procedure phone %phonecall lifeline
    locate (4, 1)
    put "Freind: Hi" ..
    locate (5, 1)
    put "You: *Tells question to friend*" ..
    locate (6, 1)

    randint (valran, 1, 20)
    if valran <= value then
        put "Freind:I am really not sure, sorry!" ..
    else
        put "Freind: I think the answer ", right_answer ..
    end if
    get answer
end phone

procedure right %procedure it goes through to check if answer is correct
    locate (2, 1)
    if answer = right_answer then
        locate (8, 1)
        put "YOU ARE RIGHT!!!" ..
        locate (9, 1)
        put "Press any key to go to next question" ..
        getch (reply)
    else
        locate (8, 1)
        put "Wrong, you lose the game" ..
        getch (reply)
    end if
end right

procedure format %the game format or where everything is placed

    drawbox (1, 1, maxx, 100, white) % options box
    drawline (maxx div 2, 1, maxx div 2, 100, white)
    drawline (1, 50, maxx, 50, white)

    drawline (1, 180, maxx, 180, white) %box in question

    drawline (maxx div 2, 180, maxx div 2, maxy, white) % vertical line

    locate (1, 55)
    put "INSTRUCTIONS"
    locate (2, 42)
    put "-Select 1,2,3 or 4 as your answer"
    locate (3, 42)
    put "-Typing 5,6 or 7 will bring lifelines"
    locate (4, 42)
    put "-5 gives the fifty-fifty lifeline"
    locate (5, 42)
    put "-6 gives the phonecall lifeline."
    locate (6, 42)
    put "-7 lets you ask the audience."
   
    %where the choices are places
    locate (15, 2)
    put question ..
    locate (21, 2)
    put choicea ..
    locate (21, 42)
    put choiceb ..
    locate (24, 2)
    put choicec ..
    locate (24, 42)
    put choiced ..

    locate (18, 2)
    put "What will you choose?" ..
    get answer
   
    if answer = 5 then%lifelines
        fiftyfifty
    elsif answer = 6 then
        phone
    end if
    right
end format

%%%%%The next series of procedures are just the questions themself
procedure onehundred %$100 question
    cls
    value := 1
    put "For $100:"
    put ""
    question := "What is the Capital of Canada?"
    choicea := "1)Quebec"
    choiceb := "2)Ontario"
    choicec := "3)Ottawa"
    choiced := "4)Toronto"

    right_answer := 3
    format
end onehundred

procedure twohundred %$200 question
    cls
    value := 2
    put "For $200:"
    put ""
    question := "What are the three forms of matter?"
    choicea := "1)Solid, Liquid and Gas"
    choiceb := "2)Solid, Liquid and Air"
    choicec := "3)Ice, Water and Steam"
    choiced := "4)Solid, Liquid and plasma"

    right_answer := 1
    format
end twohundred

onehundred
twohundred


EDIT: Ok guys, the great sofa_king has done it again Razz lol jk.i got the 50/50 thing by myself eventually. im still having a lot of trouble EXITING the game when a question is answered wrong (ive studied some source codes and ppl used booleans but i dont noe how to use booleans, another method would be GREATLY appreciated) and i also need something to prevent the user from choosing a lifeline again in another turn.

After that, all i hav to do is add more questions, add a little grease and im done
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  [ 2 Posts ]
Jump to:   


Style:  
Search: