Advertisement
Guest User

Rhombus.cs

a guest
Feb 21st, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.39 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Exercise1
  8. {
  9.     class Rhombus
  10.     {
  11.         int height;
  12.  
  13.         public Rhombus(int _height)
  14.         {
  15.             this.height = _height;
  16.             DrawTop();
  17.             DrawBottom();
  18.         }
  19.  
  20.         void DrawTop()
  21.         {
  22.             for (int row = 0; row < height; row++)
  23.             {
  24.                 if (row!=height)
  25.                 {
  26.                     for (int i = 0; i < height-row; i++)
  27.                     {
  28.                         Console.Write(" ");
  29.                     }
  30.                 }
  31.                 for (int column = 0; column < row+1; column++)
  32.                 {
  33.                     Console.Write("* ");
  34.                 }
  35.                 Console.WriteLine();
  36.             }
  37.         }
  38.         void DrawBottom()
  39.         {
  40.             for (int row = height-1; row >0; row--)
  41.             {
  42.                 if (row != height)
  43.                 {
  44.                     for (int i = 0; i < height - row + 1; i++)
  45.                     {
  46.                         Console.Write(" ");
  47.                     }
  48.                 }
  49.                 for (int column = row; column >0 ; column--)
  50.                 {
  51.                     Console.Write("* ");
  52.                 }
  53.                 Console.WriteLine();
  54.             }
  55.         }
  56.  
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement