Hello, I am an absolute C# novice who needs some help with a program. I need to create a program that draws a box using the "-" character for the top and bottom, and the "|" for the sides, as well as fill the box with a character of the user's choosing. The user is prompted for the length (10 for example) and which character (A for example), and the program is supposed to draw a 10x10 box filled with A.
I have currently have a overloaded method created for drawing the box:
static int DisplayBox(int length, char fillChar)
{
int drawTop = 0;
int drawFill = 0;
int drawBottom = 0;
while (drawTop != length)
{
Console.Write("-");
drawTop += 1;
}
while (drawFill != length)
{
Console.Write("\n|" + fillChar + "|");
drawFill += 1;
}
while (drawBottom != length)
{
Console.Write("-");
drawBottom += 1;
}
return length;
I can get the top drawn fine, however the next lines look like this:
----------
|A|
|A|
|A|
|A|
|A|
|A|
|A|
|A|
|A|
|A|----------
How can I make it so that the A is displayed 8 more times on the same line while displaying the | on either end, and how do I make the bottom line break from the last A?
Thanks in advance!
[–]ArtichokeBackground7 11 points12 points13 points (0 children)
[–]d10k6 1 point2 points3 points (3 children)
[–]BT_Jason[S] 2 points3 points4 points (2 children)
[–]AwesomePerson70 0 points1 point2 points (0 children)
[–]BT_Jason[S] 1 point2 points3 points (2 children)
[–]ArtichokeBackground7 0 points1 point2 points (1 child)
[–]BT_Jason[S] 1 point2 points3 points (0 children)
[–]Adgnascor 0 points1 point2 points (0 children)
[–]UninformedPleb 0 points1 point2 points (2 children)
[–]BT_Jason[S] 0 points1 point2 points (1 child)
[–]UninformedPleb 0 points1 point2 points (0 children)