Computer Science Canada HELP...How do i make this code work? |
Author: | bark52 [ Wed Jun 01, 2005 2:35 pm ] |
Post subject: | HELP...How do i make this code work? |
I have a program for school and this is what I have so far. I need to be able to choose a square or circle and then choose a colour for that choice. This is my code: Code: %Choose a square or circle %Choose a colour put "What object you would like to use" %See choice of square or circle drawbox (400, 300, 300, 200, 7) drawoval (350, 100, 50, 50, 7) %Use shape as a varibale var shape : int %Show text of choices with 1 being Square and 2 being Circle put "Square - 1 or Circle - 2?" %Get response get shape %clear screen Draw.Cls %If square is chosen draw square if shape = 1 then drawbox (400, 300, 300, 200, 7) %if square is not choosen draw circle else drawoval (350, 100, 50, 50, 7) end if %Pick your colour var c : int %Show text of colour choices put "Choose colour to fill shape" put "1 - Red" put "2 - Blue" put "3 - Random" %Get answer get c %If red- 1 draw redbox if c = 1 then drawfillbox (400, 300, 300, 200, 12) end if %if blue -2 draw bluebox if c = 2 then drawfillbox (400, 300, 300, 200, 1) end if %if random -3 draw randombox if c = 3 then %loop through colours 1-15 loop for i : 1..15 colour (i) drawfillbox (400, 300, 300, 200, i) delay (750) end for end loop end if Any help on how to do this? |
Author: | lyam_kaskade [ Wed Jun 01, 2005 2:49 pm ] | ||
Post subject: | |||
What exactly is wrong with it? Also, use the code tags.
|
Author: | Neo [ Wed Jun 01, 2005 3:11 pm ] |
Post subject: | |
You really dont need that for loop. Basically here is what you want. First you ask the user to choose a shape, if 1 then draw the circle else draw the square. Then you ask for a colour. If the user replies 1 then assign the variable that stores the colour with the number corresponding to which ever colour you want. Then use that variable in the colour paremeter when drawing your shape. |