Advertisement
alexey3017

Untitled

Mar 23rd, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.31 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace Learn1
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             int health;
  13.             Console.WriteLine("Введите количество вашего здоровья,максимальное значение:100");
  14.             health = Convert.ToInt32(Console.ReadLine());
  15.  
  16.             DrawBar(health);
  17.         }
  18.         static void DrawBar(int health)
  19.         {
  20.             int healthcount = health / 10;
  21.             string bar = "";
  22.             if (health <= 100 && health > 0)
  23.             {
  24.                 for (int i = 0; i < healthcount; i++)
  25.                 {
  26.                     bar += '#';
  27.                 }
  28.                 for (int i = 0; i < 10 - healthcount; i++)
  29.                 {
  30.                     bar += '_';
  31.                 }
  32.                 Console.Clear();
  33.                 Console.WriteLine($"ХП БАР:");
  34.                 Console.Write('[');
  35.                 Console.Write(bar);
  36.                 Console.Write(']');
  37.             }
  38.             else
  39.             {
  40.                 Console.WriteLine("Вы ввели неверное значение");
  41.             }
  42.             Console.ReadKey();
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement