Advertisement
dxoraxs

Untitled

Apr 16th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.49 KB | None | 0 0
  1. using System;
  2.  
  3. namespace homework
  4. {
  5.     class Program
  6.     {
  7.         static void setHealthBar(int maxValue = 10, int health=4, int positionX=10, int positionY=10, char charSign='#')
  8.         {
  9.             Console.SetCursorPosition(positionX, positionY);
  10.             string str = "[";
  11.             for (int i = 0; i < maxValue; i++) if (i < health) str += charSign;
  12.             else str += "_";
  13.             str += "]\n";
  14.             Console.Write(str);
  15.         }
  16.        
  17.         static void Main(string[] args)
  18.         {
  19.             Console.WriteLine("Вводить значения? Y/N");
  20.             if (Console.ReadLine() == "Y")
  21.             {
  22.                 int maxValue, health, posX, posY;
  23.                 char charSign;
  24.                 Console.WriteLine("Максимальное значение здоровья: ");
  25.                 maxValue = Convert.ToInt32(Console.ReadLine());
  26.                 Console.WriteLine("Значение здоровья: ");
  27.                 health = Convert.ToInt32(Console.ReadLine());
  28.                 Console.WriteLine("Position X = ");
  29.                 posX = Convert.ToInt32(Console.ReadLine());
  30.                 Console.WriteLine("Position Y = ");
  31.                 posY = Convert.ToInt32(Console.ReadLine());
  32.                 Console.WriteLine("Значек : ");
  33.                 charSign = Console.ReadKey().KeyChar;
  34.                 setHealthBar(maxValue, health, posX, posY, charSign);
  35.             }
  36.             else setHealthBar();
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement