elena1234

Rhombus of Stars - drawing on the console

Mar 16th, 2021 (edited)
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using System;
  2.  
  3. namespace RhombusOfStars
  4. {
  5.     public class Rhombus
  6.     {
  7.         public Rhombus(int size)
  8.         {
  9.             this.Size = size;
  10.         }
  11.  
  12.         public int Size { get; }
  13.  
  14.         public void PrintTop()
  15.         {
  16.             for (int row = 0; row < this.Size - 1; row++)
  17.             {
  18.                 Console.Write(new string(' ', this.Size - 1 - row));
  19.                 Console.WriteLine(string.Join(' ', new string('*', row + 1).ToCharArray()));
  20.             }
  21.         }
  22.  
  23.         public void PrintMiddle()
  24.         {
  25.             Console.WriteLine(string.Join(' ', new string('*', this.Size).ToCharArray()));
  26.         }
  27.  
  28.         public void PrintBottom()
  29.         {
  30.             for (int row = this.Size - 2; row >= 0; row--)
  31.             {
  32.                 Console.Write(new string(' ', this.Size - 1 - row));
  33.                 Console.WriteLine(string.Join(' ', new string('*', row + 1).ToCharArray()));
  34.             }
  35.         }
  36.     }
  37. }
Add Comment
Please, Sign In to add comment