Advertisement
Rodunskiy

Untitled

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