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

Username:   Password: 
 RegisterRegister   
 how can i choose a circle and then colour with this code?
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
bark52




PostPosted: Wed Jun 01, 2005 10:43 am   Post subject: how can i choose a circle and then colour with this code?

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?
Sponsor
Sponsor
Sponsor
sponsor
neufelni




PostPosted: Wed Jun 01, 2005 11:27 am   Post subject: (No subject)

You are posting in the wrong forum. This is Source Code, not Help.
Jorbalax




PostPosted: Wed Jun 01, 2005 4:58 pm   Post subject: (No subject)

Also, you haven't really indicated what the problem is...we can't help you if we don't know what's wrong.

[EDIT] oops, MAJOR brainfart there, didn't even read the title!

My suggestion would be to use an 'and' statement, and include the shape variable in the if statement, ie

if c=1 and shape=1 then
code
end if
if c=1 and shape=2 then
code
end if

You'll have to make more if statements, but it works.
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: