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

Username:   Password: 
 RegisterRegister   
 Lottery Game
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
smith_scott_04




PostPosted: Sat Nov 08, 2003 3:11 pm   Post subject: Lottery Game

This is my lottery Game (based on the rules of lotto 649) simple yet addictive.
open for new ideas Laughing
code:

-----------------------------------------------------------------------------------

var num : array 1 .. 6 of int
var number : array 1 .. 6 of int
var tot : int := 0
var finish : boolean

%-----------------------------------------------------------

procedure RandNum ()
    var doesrepeat : boolean
    randint (num (1), 1, 49)
    for cRandNum : 2 .. 6
        loop
            doesrepeat := false
            randint (num (cRandNum), 1, 49)
            for cNewRand : 1 .. cRandNum - 1
                if num (cRandNum) = num (cNewRand) then
                    doesrepeat := true
                end if
            end for
            exit when doesrepeat = false
        end loop
    end for
end RandNum

%-----------------------------------------------------------

procedure ShowNum

    locate (9, 2)
    put "The Numbers Were: "
    locate (10, 2)
    color (red)
    put num (1), " - " ..
    put num (2), " - " ..
    put num (3), " - " ..
    put num (4), " - " ..
    put num (5), " - " ..
    put num (6)

    finish := true

end ShowNum

%-----------------------------------------------------------

procedure Guess

    for locate1 : 3 .. 52 by 5

        tot := tot + 1
        loop
            var doesrepeat : boolean := false
            loop
                locate (3, 1)
                color (255)
                put "Choose 6 Numbers (1,49): " ..
                drawfillbox (200, 350, 400, 370, white)
                get number (tot)
                doesrepeat := false
                if tot > 1 then
                    for c1 : 1 .. tot - 1
                        if number (c1) = number (tot) then
                            doesrepeat := true
                        end if
                    end for
                else
                    exit
                end if
                exit when doesrepeat = false
            end loop
            if number (tot) <= 49 then
                if tot < 6 then
                    locate (5, locate1)
                    put number (tot), " - "
                end if

                if tot > 5 then
                    locate (5, locate1)
                    put number (tot)
                end if
                exit
            end if
        end loop

        if tot = 6 then
            exit
        end if

    end for

end Guess

%-----------------------------------------------------------

procedure CheckNums

    var wrong : int := 0

    for count : 1 .. 6
        for c1 : 1 .. 6
            if num (count) = number (c1) then
                wrong := wrong + 1
            end if
        end for
    end for

    locate (7, 2)
    put "You got: ", (wrong), " right"
end CheckNums

%-----------------------------------------------------------

loop

    locate (1, 28)
    color (blue)
    put "Lotto 649 - Just Imagine"

    color (255)

    RandNum
    Guess
    CheckNums
    ShowNum

    delay (10000)
    cls
    tot := 0
end loop

-----------------------------------------------------------------------------------
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sat Nov 08, 2003 3:59 pm   Post subject: (No subject)

not bad... here's an idea though...

you know their lotto advanced subscription thingy? Where they play your numbers for you?

You should do something like that. Just repeatedly play same numbers over and over again, with a counter of how much money one's loosing Laughing
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
smith_scott_04




PostPosted: Sat Nov 08, 2003 4:58 pm   Post subject: (No subject)

Thanx, im currently working on networking the game for school, and i was thinking of allowing people to store there numbers in a text file for subscription service thingy.

thanx
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: