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

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




PostPosted: Wed May 26, 2004 9:24 pm   Post subject: Millionaire (beta) help

Yes im doing the extremely easy game millionaire game but even then I still need help Confused .

Ok so to get things started, this is merely a beta ( my teacher wants 3 versions). Im not going to use lifelines as of yet but to get the basic prog, running first. instead there will be 3 chances in this beta.

OK now to the problem. Ive only done two questions so far but I want to see if im doing it right or if anything can be used better. Im aware of DanShadow's sourcecode but i rather not use that YET because my teacher knows my capabilities (that bastard) and i want to try things for myself.

Also im planning on adding more questions for each set for the second version just so you know

code:
%Who Wants to be a Millionaire
%Sofa King
%Date Created: May 21, 2004
%This program is a quiz game where you can win up to $1,000,000

colorback (black)
cls

var reply : string (1)
var answer : int
var right_answer : int
var chance : int := 3


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
    loop
        if answer = right_answer then
            put "YOU ARE RIGHT!!!"
            put "Press any key to go to next question"..
            getch (reply)
            exit
        else
            chance := chance - 1
            put "Wrong, you have ", chance, " chances left"
           
            if chance = 0 then
                put "You lose the game, press any key to restart:" ..
                getch (reply)
                exit
            else
                put "Press any key to go to next question" ..
                getch (reply)
            end if
           
            exit
        end if
    end loop
end right

procedure onehundred
    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
    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

onehundred
twohundred
Sponsor
Sponsor
Sponsor
sponsor
Paul




PostPosted: Wed May 26, 2004 9:28 pm   Post subject: (No subject)

Well, since ur starting.
It would be easier to store all the questions and choices in one txt file, and all the corresponding right answers in another, so you won't have to hardcode all questions. And then u can get them from ur textfiles
sofa_king




PostPosted: Wed May 26, 2004 9:45 pm   Post subject: (No subject)

I think i get what ur saying and it sounds like such a lazy way.... in a good way Very Happy .

unfortunately i have no idea how to get txt files on turing but some help files will surely help me or ill just stick with my current method.
guruguru




PostPosted: Wed May 26, 2004 10:02 pm   Post subject: (No subject)

Looks good. All different types of matter are solid, liquid, gas, and plasma. You missed that one.
sofa_king




PostPosted: Thu May 27, 2004 12:17 am   Post subject: (No subject)

yes but it said THREE forms of matter. plasma doesnt really count in the three basic forms of matter. however, its still a form of matter nonetheless.
poly




PostPosted: Thu May 27, 2004 8:46 am   Post subject: (No subject)

sofa_king wrote:
I think i get what ur saying and it sounds like such a lazy way.... in a good way Very Happy .

unfortunately i have no idea how to get txt files on turing but some help files will surely help me or ill just stick with my current method.


if you havent already check out the tutorial section for reading and writing files.
beard0




PostPosted: Thu May 27, 2004 9:59 am   Post subject: (No subject)

This procedure needs some work:
code:

procedure right
    loop
        if answer = right_answer then
            put "YOU ARE RIGHT!!!"
            put "Press any key to go to next question" ..
            getch (reply)
            exit
        else
            chance := chance - 1
            put "Wrong, you have ", chance, " chances left"

            if chance = 0 then
                put "You lose the game, press any key to restart:" ..
                getch (reply)
                exit
            else
                put "Press any key to go to next question" ..
                getch (reply)
            end if

            exit
        end if
    end loop
end right


You have a loop, but you always exit it without ever looping - so get rid of the loop. Also, the nested if statement is uneccary, and you tell the loser that they have 0 chances left before they get booted out, which is not needed - try this:
code:

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

Another thing - Although you don't notice it yet with only two questions, the way you have it set up, even if they loose all their chances, they won't get booted out - they'll keep playing up to the million. You need if statements checking for chance=0 outside of the right procedure as well.
Hope this helps you out!
sofa_king




PostPosted: Thu May 27, 2004 9:08 pm   Post subject: (No subject)

Thanx a crapload people Smile . Youve all been really helpful. Ill see if i can use the txt method
Sponsor
Sponsor
Sponsor
sponsor
Paul




PostPosted: Fri May 28, 2004 8:32 pm   Post subject: (No subject)

http://www.compsci.ca/v2/viewtopic.php?t=5
roer




PostPosted: Fri May 28, 2004 11:30 pm   Post subject: (No subject)

guruguru wrote:
Looks good. All different types of matter are solid, liquid, gas, and plasma. You missed that one.


Theres 5 if you want to go like that: solid,liquid,gas,plasma and bose-einstein condensates
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  [ 10 Posts ]
Jump to:   


Style:  
Search: