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 dz1
- {
- class Program
- {
- static void Main(string[] args)
- {
- DrawBar(30, 5, 30);
- Console.ReadKey();
- }
- static void DrawBar(int x, int y, int valueInPercents, int maxValue = 100, ConsoleColor valueColor = ConsoleColor.White)
- {
- int valuePerChar = maxValue / 10;
- float percents = Convert.ToSingle(valueInPercents) / 100;
- float charsQuantity = maxValue * percents / valuePerChar;
- Console.SetCursorPosition(x, y);
- Console.ForegroundColor = valueColor;
- Console.Write("[");
- for (int i = 0; i < 10; i++, charsQuantity--)
- {
- if (charsQuantity > 0)
- {
- Console.Write("#");
- }
- else
- {
- Console.Write(" ");
- }
- }
- Console.Write("]");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement