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

Username:   Password: 
 RegisterRegister   
 Help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Lytes




PostPosted: Thu Feb 20, 2003 3:25 am   Post subject: Help

Hey I'm in na grade 10 computer programming class and I am stuck in this turing and I need some help. We're just starting so I'm not that great and this is just a little assignment and I need someone to help me. I need to get my color variable in the drawbox and drawoval options. I got all the x and y coordinates in there but whenever I try to put color it won't work, someone please tell me how to do this!! I will post everything I got on here now and it's all right except the color wont work, please help me!!!

% This is a program to
% Draw A Shape

var choice : string
var x1 : int
var x2 : int
var y1 : int
var y2 : int
var answer : string
var any : string
var colo : string

loop
cls

put "What shape would you like to draw?" ..
put " "
put "Enter r to draw a rectangle" ..
put " "
put "Enter c to draw a circle"
put " "
get choice
if choice = "r" then
put "What is the first x coordinate that you'd like to have for the size of the rectangle? "
get x1
put "What is the first y coordinate that you'd like to have for the size of the rectangle? "
get y1
put "What is the second x coordinate that you'd like to have for the size of the rectangle? "
get x2
put "What is the second y coordinate that you'd like to have for the size of the rectangle? "
get y2
put "What color would you want the box to be? "
get colo
cls
drawfillbox (x1,y1,x2,y2,colo)
elsif choice = "c" then
put "What is the first x coordiante that you'd like to have for the size of the circle? x1: "
get x1
put "What is the first y coordinate that you'd like to have for the size of the circle? y1: "
get y1
put "What is the second x coordinate that you'd like to have for the size of the circle? x2: "
get x2
put "What is the second y coordinate that you'd like to have for the size of the circle? y2: "
get y2
put "What color would you want the oval to be? "
get colo
cls
drawfilloval (x1,y1,x2,y2,colo)
put "Press any key to continue. "
get any
end if
put " "
put "Would you like to try this again??? " ..
put "Press n for no or y for yes. "
get answer
if answer = "y" then
end if
if answer = "n" then
cls
put "Thanks for using the program!!!"
exit
end if
end loop
Sponsor
Sponsor
Sponsor
sponsor
DarkHelmet




PostPosted: Thu Feb 20, 2003 7:51 am   Post subject: (No subject)

The problem is that drawfillbox can't accept a string as the colour. You can use an integer. The program recognizes predefined words as colours, like black, but it doesn't recognize the text in the strings as being equal to those words. you could use an if statement like :

if colo = "black" then
drawfillbox (x1,y1,x2,y2, black)
elsif colo = "yellow" then
drawfillbox (x1,y1,x2,y2, yellow)
etc.
end if

Other people might have better ideas, but this is the only one i can think of right now.
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  [ 2 Posts ]
Jump to:   


Style:  
Search: