Advertisement
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 UIElement_03
- {
- class Program
- {
- static void Main(string[] args)
- {
- int value = 12;
- int maxValue = 20;
- int relativeSize = 100;
- DisplayBar(value, maxValue, relativeSize);
- Console.ReadKey();
- }
- static void DisplayBar(int value, int maxValue, int relativeSize, char symbol = ' ')
- {
- int percent = value * 100 / maxValue;
- int coloredPercent = value * relativeSize / maxValue;
- Console.SetCursorPosition(0, 1);
- Console.WriteLine($"Относительный размер полоски: ");
- Console.WriteLine($"{value} от {maxValue} это {percent}%. При размере полоски в {relativeSize} ячеек, закрашиваем {coloredPercent} из них.");
- string bar = "";
- for (int i = 0; i < coloredPercent; i++)
- {
- bar += symbol;
- }
- Console.Write('[');
- ConsoleColor defaultColor;
- defaultColor = Console.BackgroundColor;
- Console.BackgroundColor = ConsoleColor.DarkRed;
- Console.Write(bar);
- Console.BackgroundColor = defaultColor;
- bar = "";
- for (int i = coloredPercent; i < relativeSize; i++)
- {
- bar += symbol;
- }
- Console.WriteLine($"{bar}]");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement