Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Tasks
- {
- class Program
- {
- static void Main(string[] args)
- {
- int health = 5;
- int maxHealth = 20;
- Console.WriteLine("Здравствуйте, в какой позиции вы хотите нарисовать шкалу?");
- Console.WriteLine("Последовательно введите координаты по осям X и Y.");
- int xPos = Convert.ToInt32(Console.ReadLine());
- int yPos = Convert.ToInt32(Console.ReadLine());
- Console.SetCursorPosition(xPos, yPos);
- PaintBar(health, maxHealth, ConsoleColor.Green);
- }
- static void PaintBar(int value, int maxValue, ConsoleColor color)
- {
- ConsoleColor oldColor = Console.ForegroundColor;
- Console.Write("[");
- int empty = maxValue - value;
- for (int i = 0; i <= value; i++)
- {
- Console.ForegroundColor = color;
- Console.Write("*");
- }
- for (int j = 0; j < empty; j++)
- {
- Console.ForegroundColor = Console.BackgroundColor;
- Console.Write(" ");
- }
- Console.ForegroundColor = oldColor;
- Console.WriteLine("]");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment