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

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




PostPosted: Thu Oct 29, 2009 8:36 am   Post subject: Depth, Width... Box.

Hey guys, I need help with a problem I made myself a code, it asks for the width and the depth of a box, then draws the top and bottom lines accordingly using the turing coloring scheme.


now I need make the program to add the side lines to the box, to complete it. keeping the color scheme consistent to what it is, for the existing portion of the program.


----------------------------- |
|
| <- depth
|
|
|
----------------------------- |
^
width

here is my code.


Turing:


var depth, width : int
put "Enter the width of the box (less than 60)"
get width
put "Enter the depth of the box (less than 20)"
get depth

cls
% Arrange to center box in window
const topRow := (25 - depth) div 2
const leftColumn := (80 - width) div 2
var colorNo : int

% Draw top of box
locate (topRow, leftColumn)
for count : 1 .. width

% Choose Random color
randint (colorNo, 0, 15)
% Set the color
color (colorNo)

put "*" ..
end for

% Draw bottom of box

locate (topRow + depth - 1, leftColumn)
for count : 1 .. width
randint (colorNo, 0, 15)
color (colorNo)

put "*" ..
end for



Please help me.
Sponsor
Sponsor
Sponsor
sponsor
MossyMossy




PostPosted: Thu Oct 29, 2009 10:51 am   Post subject: Re: Depth, Width... Box.

GOT IT!! thanks tho ^,^


var depth : int
var width : int
put "Enter the width of the box (less than 60)"
get width
put "Enter the depth of the box (less than 20)"
get depth
cls
const topRow := (25 - depth) div 2
const leftColumn := (80 - width) div 2
var colorNo : int
locate (topRow, leftColumn)
for count : 1 .. width

randint (colorNo, 0, 15)
color (colorNo)
put "*" ..
end for
locate (topRow + depth - 1, leftColumn)
for count : 1 .. width
randint (colorNo, 0, 15)
color (colorNo)
put "*" ..
end for
const sideTop := topRow + 1
const sideBottom := topRow + depth - 2
for row : sideTop .. sideBottom
randint (colorNo, 0, 15)
color (colorNo)
locate (row, leftColumn)
put "*" ..
end for
const rightColumn := leftColumn + width - 1
for row : sideTop .. sideBottom
randint (colorNo, 0, 15)
color (colorNo)
locate (row, rightColumn)
put "*" ..
end for
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: