This is quite straight forward.
Let's look at how the box is made up.
It has two full lines of characters at the top and at the bottom, and the bit between has two chars at the start and two chars at the end with spaces in between.
Let's say the width is X characters, this also happens to be the number of lines height. (int width =X)
We can see that the number of spaces in each line is X-4
The middle part is X-4 lines high
The general code procedure would look something like this.
1. Draw a full line of chars + newline (you know how to do that)
2. Draw another full line of chars + newline
1 2
|
int numSpaces = width-4;
int middleHeight = width-4;
|
3. Now a for loop equal to the middleHeight
for (int count=0; count < middleHeight; count++)
{
3.1 draw two chars at the start of the line
3.2 now an inner for loop for the spaces
for (int spaceCount=0; spaceCount < numSpaces; spaceCount++)
{
loop and Draw spaces
}//end space loop
3.3 Draw two chars to end the line + newline
3.4 } //End middleHeight loop
4. Draw a full line of chars + carriage return
5. Draw another full line of chars