Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Task29
- {
- class Program
- {
- static void Main(string[] args)
- {
- char startSymbol = '_';
- char symbolHealth = '#';
- int health;
- int maxHealth = 10;
- int percentHealthHerro;
- int positionVertical = 5;
- int halfFromWhole = 5;
- Console.Write("Введите процент здоровья героя: ");
- percentHealthHerro = Convert.ToInt32(Console.ReadLine());
- health = percentHealthHerro / maxHealth;
- if (maxHealth % percentHealthHerro >= halfFromWhole)
- {
- health++;
- }
- DrawBar(health, maxHealth, positionVertical, startSymbol, symbolHealth);
- }
- static void DrawBar(int value, int maxValue, int position, char startSymbolol = ' ', char symbolHealth = ' ')
- {
- Console.Clear();
- string bar = "";
- for (int i = 0; i < value; i++)
- {
- bar += symbolHealth;
- }
- Console.SetCursorPosition(0, position);
- Console.Write('[');
- Console.Write(bar);
- bar = "";
- for (int i = value; i < maxValue; i++)
- {
- bar += startSymbolol;
- }
- Console.Write(bar + ']');
- }
- }
- }
Add Comment
Please, Sign In to add comment