Advertisement
NelIfandieva

Figure_Class

Jan 13th, 2020
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace Svetlina_Lab
  6. {
  7.     public class Figure
  8.     {
  9.         private int scale;
  10.  
  11.         public Figure(int scale)
  12.         {
  13.             this.Scale = scale;
  14.         }
  15.  
  16.         public int Scale { get; set; }
  17.  
  18.         private void DrawUpper()
  19.         {
  20.             int height = this.Scale;
  21.  
  22.             char bckgrndHyphen = '-';
  23.             int bckgrndHyphenStartNum = 3 * this.Scale;
  24.  
  25.             char axeSymbol = '*';
  26.             int axeNum = 1;
  27.  
  28.             char innerSymbol = '-';
  29.             int innerNum = 0;
  30.  
  31.             int bckgrndHyphenEndNum = this.Scale * 2 - 2;
  32.  
  33.             for (int i = 1; i <= height; i++)
  34.             {
  35.                 Console.WriteLine("{0}{1}{2}{1}{3}", new string(bckgrndHyphen, bckgrndHyphenStartNum), new string(axeSymbol, axeNum), new string(innerSymbol, innerNum), new string(bckgrndHyphen, bckgrndHyphenEndNum));
  36.                 innerNum++;
  37.                 bckgrndHyphenEndNum--;
  38.             }
  39.         }
  40.  
  41.         private void DrawHandle()
  42.         {
  43.             int handleHeight = this.Scale / 2;
  44.  
  45.             char handleSymbol = '*';
  46.             int handleSymbolNum = 3 * this.Scale;
  47.  
  48.             char axeSymbol = '*';
  49.             int axeSymbolNum = 1;
  50.  
  51.             char inner = '-';
  52.             int innerNum = this.Scale - 1;
  53.  
  54.             for(int i = 1; i <= handleHeight; i++)
  55.             {
  56.                 Console.WriteLine("{0}{1}{2}{1}{2}", new string(handleSymbol, handleSymbolNum), new string(axeSymbol, axeSymbolNum), new string(inner, innerNum));
  57.             }
  58.         }
  59.  
  60.         private void DrawLower()
  61.         {
  62.             int lowerHeight = this.Scale / 2;
  63.  
  64.             char bckgrndSymbol = '-';
  65.             int bckgrndNum = this.Scale * 3;
  66.  
  67.             char axeSymbol = '*';
  68.             int axeNum = 1;
  69.  
  70.             char inner = '-';
  71.             int innerNum = this.Scale - 1;
  72.  
  73.             char endSymbol = '-';
  74.             int endNum = this.Scale - 1;
  75.  
  76.             for (int i = 1; i <= lowerHeight; i++)
  77.             {
  78.                 if(i < lowerHeight)
  79.                 {
  80.                     Console.WriteLine("{0}{1}{2}{1}{3}", new string(bckgrndSymbol, bckgrndNum), new string(axeSymbol, axeNum), new string(inner, innerNum), new string(endSymbol, endNum));
  81.                     bckgrndNum--;
  82.                     innerNum += 2;
  83.                     endNum--;
  84.                 }
  85.                 else
  86.                 {
  87.                     int width = this.Scale * 5;
  88.                     int axeSymbolNum = (width - ((bckgrndNum - 1) + endNum)) - 1;
  89.                     Console.WriteLine("{0}{1}{2}", new string(bckgrndSymbol, bckgrndNum), new string(axeSymbol, axeSymbolNum), new string(endSymbol, endNum));
  90.                 }
  91.             }
  92.         }
  93.  
  94.         public void DrawFigure()
  95.         {
  96.             DrawUpper();
  97.             DrawHandle();
  98.             DrawLower();
  99.         }
  100.     }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement