Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Homework4
- {
- class Program
- {
- static void Main(string[] args)
- {
- int percentHealth;
- int percentMana;
- Console.SetCursorPosition(0, 20);
- Console.Write("Введите процент здоровья - ");
- percentHealth = Convert.ToInt32(Console.ReadLine());
- Console.Write("Введите процент маны - ");
- percentMana = Convert.ToInt32(Console.ReadLine());
- Console.SetCursorPosition(0, 0);
- DrawBar(percentHealth, ConsoleColor.Red);
- DrawBar(percentMana, ConsoleColor.Blue);
- }
- static void DrawBar(int percent, ConsoleColor color)
- {
- int currentBarValue = percent / 10;
- ConsoleColor defaultColor = Console.BackgroundColor;
- Console.Write("[");
- Console.BackgroundColor = color;
- for (int i = 0; i < currentBarValue; i++)
- {
- Console.Write("#");
- }
- Console.BackgroundColor = defaultColor;
- for (int i = currentBarValue; i < 10; i++)
- {
- Console.Write("_");
- }
- Console.Write("]\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement