Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Help
Author Message
Lytes

Posted: 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 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. "
end if
cls
put "Thanks for using the program!!!"
exit
end if
end loop

DarkHelmet

Posted: 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: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 2 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: