Computer Science Canada

Random Shape Drawer with menu

Author:  vertdragon23 [ Sat Oct 19, 2013 1:37 pm ]
Post subject:  Random Shape Drawer with menu

What is it you are trying to achieve?
<Give the user a menu to choose from the following shapes: circle, rectangle, star, square and maple leaf. Once they select a shape. Continuously display this shape on the screen until the user presses the stop button.>


What is the problem you are having?
<No idea how to start.>


Describe what you have tried to solve this problem
<Searching gui, and turing reference.>


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

Turing:


<Add your code here>



Please specify what version of Turing you are using
4.1.1 (latest)

Author:  Nathan4102 [ Sat Oct 19, 2013 1:45 pm ]
Post subject:  RE:Random Shape Drawer with menu

We don't write your homework programs, we help out. If you give it a try, and have a specific question, feel free to ask, and we'll try to help!

Author:  Raknarg [ Sat Oct 19, 2013 2:17 pm ]
Post subject:  RE:Random Shape Drawer with menu

THe first thing to do is figure out what things you need to track. What do you thing? And be very detailed. Anything that you can think of tracking, probably needs to be there

Author:  vertdragon23 [ Sat Oct 19, 2013 2:48 pm ]
Post subject:  RE:Random Shape Drawer with menu

This is what I have so far. Can anyone help me with procedure and how I can make it so each option is a procedure.




Turing:

var op:int
put "What shape would you like?"
put " 1 for Circle, 2 for Rectangle, 3 for Star, 4 for Square or 5 for Maple Leaf"
get op
if op= 1 then elsif op=2 then
    for i : 1 .. 1000
        var r : int := Rand.Int (20, 50)
        var x : int := Rand.Int (r, maxx - r)
        var y : int := Rand.Int (r, maxy - r)
        var c : int := Rand.Int (0, maxcolor)
        Draw.FillBox (x, y, r, r, c)
        end for
        end if

    for i : 1 .. 10000
        var r : int := Rand.Int (20, 50)
        var x : int := Rand.Int (r, maxx - r)
        var y : int := Rand.Int (r, maxy - r)
        var c : int := Rand.Int (0, maxcolor)
        Draw.FillOval (x, y, r, r, c)
        delay (50)

end for




Mod Edit:
Please wrap you code in either of the following in order to preserve whitespace (indentation) and to highlight the syntax.
code:

[syntax="turing"] ... code ... [/syntax]

[code] ... code ... [/code ]

Author:  Raknarg [ Sat Oct 19, 2013 3:09 pm ]
Post subject:  RE:Random Shape Drawer with menu

Do you know how procedures work?

Author:  vertdragon23 [ Sat Oct 19, 2013 3:12 pm ]
Post subject:  RE:Random Shape Drawer with menu

Not really, im trying to get it so when the user enters the number listed the procedure will be called upon.

Author:  Zren [ Sat Oct 19, 2013 4:01 pm ]
Post subject:  RE:Random Shape Drawer with menu

code:
for i : 1 .. 10000


Use loop and end loop if you want an infinite loop. Then use exit when ... to exit from it when a certain condition happens (eg if a button is pressed).

code:
if op= 1 then elsif op=2 then


You should probably read through the If statements tutorial in the Turing Walkthrough.


: