Advertisement
Rodunskiy

Untitled

May 19th, 2023
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.66 KB | None | 0 0
  1. class program
  2. {
  3.     static void Main(string[] args)
  4.     {
  5.         char[] chars = {'#', '_'};
  6.         Console.Write("Введите размер строки жизней:");
  7.         int sizeHealthbar = Convert.ToInt32(Console.ReadLine());
  8.         Console.Write("Введите процент заполнения строки жизней:");
  9.         int percentHealthbar = Convert.ToInt32(Console.ReadLine());
  10.         Console.Write("Введите размер строки маны:");
  11.         int sizeManabar = Convert.ToInt32(Console.ReadLine());
  12.         Console.Write("Введите процент заполнения строки маны:");
  13.         int percentManabar = Convert.ToInt32(Console.ReadLine());
  14.  
  15.         Console.Clear();
  16.  
  17.         DrawBar(sizeHealthbar, percentHealthbar, chars[0], chars[1], 0);
  18.         DrawBar(sizeManabar, percentManabar, chars[0], chars[1], 1);
  19.     }
  20.  
  21.     static void DrawBar(int size, int percent, char symbolGrid, char symbolBottomDash, int position)
  22.     {
  23.         int divider = 100;
  24.         int zero = 0;
  25.         int transferPercentBar = (size * percent) / divider;
  26.         string bar = "";
  27.  
  28.         FillingBar(zero, transferPercentBar, ref bar, symbolGrid);
  29.  
  30.         Console.SetCursorPosition(0, position);
  31.         Console.Write('[');
  32.         Console.Write(bar);
  33.  
  34.         bar = "";
  35.  
  36.         FillingBar(transferPercentBar, size, ref bar, symbolBottomDash);
  37.  
  38.         Console.Write(bar + ']');
  39.     }
  40.  
  41.     static void FillingBar(int startPoint, int outPoint, ref string whiteSpace, char symbol)
  42.     {
  43.         for (int i = startPoint; i < outPoint; i++)
  44.         {
  45.             whiteSpace += symbol;
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement