View difference between Paste ID: df01DYTX and C26sWULh
SHOW: | | - or go back to the newest paste.
1
using System;
2
3
namespace C_sharp_Light
4
{
5
    class Program
6
    {
7
        static void Main(string[] args)
8
        {
9-
            
9+
            DrawBar(50, 10, ConsoleColor.Red, 5, 5);
10
            DrawBar(10, 16, ConsoleColor.Green, 5, 6);
11
            DrawBar(100, 20, ConsoleColor.Yellow, 5, 7);
12
            Console.ReadKey();
13
        }
14
15
        static void DrawBar(int fillingPercent, int sizeBar, ConsoleColor color, int xPos, int yPos)
16
        {
17
            if (fillingPercent > 100)
18
                fillingPercent = 100;
19
            if (fillingPercent < 0)
20
                fillingPercent = 0;
21
            int fillingPercentOfBar = sizeBar * fillingPercent / 100;
22
            Console.SetCursorPosition(xPos, yPos);
23
            for (int i = 0; i <= sizeBar + 1; i++)
24
            {
25
                if (i == 0)
26
                {
27
                    Console.ForegroundColor = ConsoleColor.White;
28
                    Console.Write('[');
29
                }
30
                else if (i == sizeBar + 1)
31
                {
32
                    Console.ForegroundColor = ConsoleColor.White;
33
                    Console.Write(']');
34
                }
35
                else if (i <= fillingPercentOfBar)
36
                {
37
                    Console.ForegroundColor = color;
38
                    Console.Write('#');
39
                }
40
                else
41
                {
42
                    Console.ForegroundColor = ConsoleColor.White;
43
                    Console.Write('_');
44
                }
45
            }
46
        }
47
    }
48
}