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

Username:   Password: 
 RegisterRegister   
 could someone please comment this code for me
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
turing1094




PostPosted: Tue Jun 15, 2010 6:35 pm   Post subject: could someone please comment this code for me

What is it you are trying to achieve?
My friend gave me this code to help me out but I dont understand it, could someone if not all comment some of it


What is the problem you are having?
I dont understand any of it I am a beginner

Describe what you have tried to solve this problem
<Answer Here>


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


setscreen ("graphics:v16,nocursor")
randomize
var wager, bank : int
var x1, x2, y1, y2, a1, a2, b1, b2, c1, c2, d1, d2, cc1, cc2, cc3, rad :
    int
var ball, choice : int
randint (rad, 20, 30)

x1 := 75
x2 := 100
y1 := maxy div 2 - 50
y2 := maxy div 2 + 50
a1 := 250
a2 := 275
b1 := maxy div 2 - 50
b2 := maxy div 2 + 50
c1 := 425
c2 := 450
d1 := maxy div 2 - 50
d2 := maxy div 2 + 50
cc1 := 4
cc2 := 9
cc3 := 14
bank := 10
colourback (255)
procedure drawcup1
    drawline (x1, y1, x2, y2, black)
    drawline (x2, y2, x2 + 60, y2, black)
    drawline (x2 + 60, y2, x2 + 85, y1, black)
    drawline (x1, y1, x2 + 85, y1, black)
    drawfill (x1 + 10, y1 + 1, cc1, black)
end drawcup1
procedure drawcup11
    drawline (x1, y1, x2, y2, 0)
    drawline (x2, y2, x2 + 60, y2, 0)
    drawline (x2 + 60, y2, x2 + 85, y1, 0)
    drawline (x1, y1, x2 + 85, y1, 0)
    drawfill (x1 + 10, y1 + 1, 0, 0)
end drawcup11

procedure drawcup2
    drawline (a1, b1, a2, b2, black)
    drawline (a2, b2, a2 + 60, b2, black)
    drawline (a2 + 60, b2, a2 + 85, b1, black)
    drawline (a1, b1, a2 + 85, b1, black)
    drawfill (a1 + 10, b1 + 1, cc2, black)
end drawcup2
procedure drawcup22
    drawline (a1, b1, a2, b2, 0)
    drawline (a2, b2, a2 + 60, b2, 0)
    drawline (a2 + 60, b2, a2 + 85, b1, 0)
    drawline (a1, b1, a2 + 85, b1, 0)
    drawfill (a1 + 10, b1 + 1, 0, 0)
end drawcup22

procedure drawcup3
    drawline (c1, d1, c2, d2, black)
    drawline (c2, d2, c2 + 60, d2, black)
    drawline (c2 + 60, d2, c2 + 85, d1, black)
    drawline (c1, d1, c2 + 85, d1, black)
    drawfill (c1 + 10, d1 + 1, cc3, black)
end drawcup3
procedure drawcup33
    drawline (c1, d1, c2, d2, 0)
    drawline (c2, d2, c2 + 60, d2, 0)
    drawline (c2 + 60, d2, c2 + 85, d1, 0)
    drawline (c1, d1, c2 + 85, d1, 0)
    drawfill (c1 + 10, d1 + 1, 0, 0)
end drawcup33

loop
    loop
        colour (white)
        locate (1, 1)
        put " You have $ ", bank, " in the bank."
        put " How much would you like to bet?: " ..
        get wager

        locate (1, 1)
        colour (white)
        put ""
        put ""
        exit when wager <= bank
    end loop
    colourback (white)
    drawcup1
    drawcup3
    locate (21, 17)
    colour (black)
    put "1"
    locate (21, 39)
    put "2"
    locate (21, 60)
    put "3"
    for i : 1 .. 10
        drawcup22
        b1 += 5
        b2 += 5
        drawcup2
    end for
    drawfilloval ((a2 + 85 + a1) div 2, maxy div 2 - 50 + 15, 15, 15, 13)
    delay (5000)
    for i : 1 .. 10
        drawcup22
        b1 -= 5
        b2 -= 5
        drawcup2
    end for
    var temp, temp2 : int
    for i : 1 .. rad
        temp := cc1
        cc1 := cc2
        temp2 := cc3
        cc2 := temp2
        cc3 := temp
        drawcup1
        drawcup2
        drawcup3
        delay (1)
        randint (ball, 1, 3)
        if ball = 1 then
            drawfilloval ((x1 + x2 + 85) div 2 - 5, y2 + 10, 3, 3, green)
            delay (200)
            drawfilloval ((x1 + x2 + 85) div 2 - 5, y2 + 10, 3, 3, 0)
        elsif ball = 2 then
            drawfilloval ((a1 + a2 + 85) div 2 - 5, b2 + 10, 3, 3, green)
            delay (200)
            drawfilloval ((a1 + a2 + 85) div 2 - 5, b2 + 10, 3, 3, 0)
        elsif ball = 3 then
            drawfilloval ((c1 + c2 + 85) div 2 - 5, d2 + 10, 3, 3, green)
            delay (200)
            drawfilloval ((c1 + c2 + 85) div 2 - 5, d2 + 10, 3, 3, 0)
        end if
    end for
    put " Which cup is the ball under: " ..
    get choice
    var reply : string (1)
    if choice = 1 then
        for i : 1 .. 10
            drawcup11
            y1 += 5
            y2 += 5
            drawcup1
        end for
        if ball = 1 then
            drawfilloval ((x2 + 85 + x1) div 2, maxy div 2 - 50 + 15, 15, 15, 13)
            delay (100)
        end if
        for i : 1 .. 10
            drawcup11
            y1 -= 5
            y2 -= 5
            drawcup1
        end for
    end if
    if choice = 2 then
        for i : 1 .. 10
            drawcup22
            b1 += 5
            b2 += 5
            drawcup2
        end for
        if ball = 2 then
            drawfilloval ((a2 + 85 + a1) div 2, maxy div 2 - 50 + 15, 15, 15, 13)
            delay (100)
        end if
        for i : 1 .. 10
            drawcup22
            b1 -= 5
            b2 -= 5
            drawcup2
        end for
    end if
    if choice = 3 then
        for i : 1 .. 10
            drawcup33
            d1 += 5
            d2 += 5
            drawcup3
        end for
        if ball = 3 then
            drawfilloval ((c2 + 85 + c1) div 2, maxy div 2 - 50 + 15, 15, 15, 13)
            delay (100)
        end if
        for i : 1 .. 10
            drawcup33
            d1 -= 5
            d2 -= 5
            drawcup3
        end for
    end if
    colourback (black)
    colour (white)
    if choice = ball then
        bank += wager
        put "Congratulations you win $ ", wager
        put " Would you like to play again? (y or n)" ..
        get reply
        if reply = "n" then
            exit
        else
            locate (22, 1)
            colour (white)
            put ""
            put ""
            put ""
        end if
    else
        put " HAHA you lose $ ", wager
        bank -= wager
        if bank < 1 then
            put " You is BANKRUPT! "
            exit
        else
            put " Would you like to play again? (y or n)" ..
            get reply
            if reply = "n" then
                exit
            else
                locate (22, 1)
                colour (white)
                put ""
                put ""
                put ""

            end if
        end if
    end if
end loop




Please specify what version of Turing you are using
<Answer Here>
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Tue Jun 15, 2010 6:38 pm   Post subject: RE:could someone please comment this code for me

Nope. If you don't understand it, ask your friend to explain it. We won't do your work for you.
turing1094




PostPosted: Tue Jun 15, 2010 8:35 pm   Post subject: Re: could someone please comment this code for me

please help hes gone to mexico and i really need some help
atleast help with some of it
Monduman11




PostPosted: Tue Jun 15, 2010 8:44 pm   Post subject: RE:could someone please comment this code for me

my guess is that he copied it from somewhere and now he has no clue how it works Smile
edit: to be honest with u i looked at the code and the majority of it is stuff that you can figure out just by reading it and using the break key to pause it at any moment.. so figure it out its not hard Razz
USEC_OFFICER




PostPosted: Wed Jun 16, 2010 11:42 am   Post subject: RE:could someone please comment this code for me

Why do you have to know what it does? It does look pretty simple. (Better than the mess of code that I can come up with.)
Cezna




PostPosted: Wed Jun 16, 2010 2:22 pm   Post subject: RE:could someone please comment this code for me

That is way too much code to expect people to read through and explain.

Anyway, it dosen't matter, as I suspect Monduman is right.
A.J




PostPosted: Wed Jun 16, 2010 3:51 pm   Post subject: RE:could someone please comment this code for me

Here at compsci.ca we don't do your work for you, ESPECIALLY when it isn't your code in the first place that is in question. So I apologize, there's nothing we can do.
Srlancelot39




PostPosted: Tue Sep 28, 2010 6:45 pm   Post subject: RE:could someone please comment this code for me

why is he giving you code you dont know how to use?.....why is he giving you code at all?
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: