Advertisement
PRO100LY4UK

4.2

Sep 6th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.42 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp13
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int x, y,healthPercents;
  10.             Console.Write("Введите значение x:");
  11.             x = Convert.ToInt32(Console.ReadLine());
  12.             Console.Write("Введите значение y:");
  13.             y = Convert.ToInt32(Console.ReadLine());
  14.             Console.Write("Введите количество здоровья в процентах:");
  15.             healthPercents = Convert.ToInt32(Console.ReadLine());
  16.             Console.Clear();
  17.             drowHealthBar(x,y,healthPercents);
  18.  
  19.         }
  20.  
  21.  
  22.         static void drowHealthBar(int x1,int y1, int healthPercents1)
  23.         {
  24.             int max = 10;
  25.             string health = "";
  26.             ConsoleColor defaultColor = Console.BackgroundColor;
  27.            
  28.             for (int i = 0; i < healthPercents1; i++)
  29.             {
  30.                 health += ' ';
  31.             }
  32.             Console.SetCursorPosition(x1, y1);
  33.             Console.Write('[');
  34.             Console.BackgroundColor = ConsoleColor.DarkRed;
  35.             Console.Write(health);
  36.             health = "";
  37.             Console.BackgroundColor = default;
  38.             for (int i = healthPercents1; i < max; i++)
  39.             {
  40.                 health += ' ';
  41.             }
  42.             Console.Write(health + ']');
  43.            
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement