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

Username:   Password: 
 RegisterRegister   
 Super7
Index -> Programming, Turing -> Turing Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Catalyst




PostPosted: Wed Nov 12, 2003 1:05 pm   Post subject: (No subject)

tony- u should look at the OOP in c++, it might not be as "correct" as it is in java but it is really powerful (mutiple inheritance, abstract functions/classes, etc)
Sponsor
Sponsor
Sponsor
sponsor
smith_scott_04




PostPosted: Wed Nov 12, 2003 6:38 pm   Post subject: I Have Already Wrote The Program

Here is the lotto 649 game just change a few variables.

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

Chimaera




PostPosted: Wed Nov 12, 2003 7:34 pm   Post subject: (No subject)

you can't exit your program without doing it manually. Perhaps you should modify your program to do so, but other than that nice program. It doesn't have much to do with Super 7 though.
Tony




PostPosted: Wed Nov 12, 2003 11:52 pm   Post subject: (No subject)

blade - obviously mine is simpler AND has better execution time... has less lines of code too Laughing
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
compudave




PostPosted: Thu Nov 13, 2003 12:52 am   Post subject: (No subject)

Laughing hehe, You said it Tony...
hackman




PostPosted: Thu Nov 13, 2003 11:40 am   Post subject: (No subject)

I had to do the same program, my teacher was happy with a simple

code:
put "Would you like to re-generate the numbers? <y/n>"
if ans="n" then
...
...
...
...
Tony




PostPosted: Thu Nov 13, 2003 3:18 pm   Post subject: (No subject)

well the chances of
code:

for i:1..10
put Rand.Int(1,10)
end for


to generate a list of 10 unique numbers...

is 1 in 10*9*8...*1
Twisted Evil
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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 2 of 2  [ 22 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: