Advertisement
Normantas

A rectangle drawing function with custom variables TEXT-ONLY

Dec 15th, 2019
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. public static void DrawRectangle(int length, int height, int thickness)
  2.         {
  3.             //Converts to an absolute, so incase if a negative number is used, it can still work and doesn't 'brick' the function
  4.             int x = Math.Abs(length);
  5.             int y = Math.Abs(height);
  6.             int t = Math.Abs(thickness);
  7.             for (int i = 0; i < y; i++)
  8.             {
  9.                 for (int l = 0; l < x; l++)
  10.                 {
  11.                     if (i < t || i > y - t - 1 || l < t || l > x - t - 1)
  12.                         Console.Write("#");
  13.                     else
  14.                         Console.Write("=");
  15.                     Console.Write(" "); //REMOVE THIS IF WANTED, as it only adds a space so it looks nicer in the final product
  16.                 }
  17.                 Console.WriteLine();
  18.             }
  19.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement