Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace CSLight
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int healthPercent = 0;
- int manaPercent = 0;
- int maxValue = 10;
- int maxPercent = 100;
- while (maxPercent >= healthPercent && maxPercent >= manaPercent)
- {
- DrawnBar(maxValue, healthPercent, 0);
- DrawnBar(maxValue, manaPercent, 2);
- Console.SetCursorPosition(0, 4);
- Console.WriteLine("Введите желаемый процент(%) жизни (от 0 до 100): ");
- healthPercent = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Введите желаемый процент(%) маны (от 0 до 100): ");
- manaPercent = Convert.ToInt32(Console.ReadLine());
- Console.ReadKey();
- Console.Clear();
- }
- }
- static void DrawnBar(int maxValue, int percent, int position)
- {
- string tempBar;
- char openSymbol = '[';
- char closeSymbol = ']';
- char percentSymbol = '#';
- char excessSymbol = '_';
- int percentLength = percent / maxValue; ;
- int excessLength = maxValue - percentLength;
- Console.SetCursorPosition(0, position);
- tempBar = FillLine(percentLength, symbol: percentSymbol);
- Console.Write(openSymbol + tempBar);
- tempBar = FillLine(excessLength, symbol: excessSymbol);
- Console.Write(tempBar + closeSymbol);
- }
- static string FillLine(int value, char symbol)
- {
- string bar = "";
- for (int i = 0; i < value; i++)
- {
- bar += symbol;
- }
- return bar;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement