Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- internal class Program
- {
- static int MaxPercent = 100;
- static int LengthBar = 10;
- static char Sing = '#';
- static char EmtySing = '_';
- static void Main(string[] args)
- {
- DrawBar(40, ConsoleColor.Green, 0, 0);
- DrawBar(80, ConsoleColor.Blue, 30, 0);
- Console.ReadKey();
- }
- static void DrawBar(int filledPercent, ConsoleColor color, int positionX, int positionY)
- {
- int remainingPoints = filledPercent * LengthBar / MaxPercent;
- int emptyPoints = LengthBar - remainingPoints;
- ConsoleColor defaultColor = Console.ForegroundColor;
- string bar = "";
- FillBar(ref bar, remainingPoints, Sing);
- FillBar(ref bar, emptyPoints, EmtySing);
- Console.SetCursorPosition(positionX, positionY);
- Console.Write('[');
- Console.ForegroundColor = color;
- Console.Write(bar);
- Console.ForegroundColor = defaultColor;
- Console.Write(']');
- }
- static void FillBar(ref string bar, int cauntPoint, char sing)
- {
- for (int i = 0;i < cauntPoint;i++)
- {
- bar += sing;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement