Benjail

4.2

Sep 2nd, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.26 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Healthbar
  4. {
  5.     class Program
  6.     {
  7.         static string vvod(ref string prozent)
  8.         {
  9.             prozent = Console.ReadLine();
  10.             return prozent;
  11.         }
  12.  
  13.         static void Drawbar (double value,double maxvalue)
  14.         {
  15.  
  16.             ConsoleColor defaultColor = Console.BackgroundColor;
  17.             string bar = "";
  18.             for(int i=0;i<(value/10-1);i++)
  19.             {
  20.                 bar += '#';
  21.             }
  22.             Console.SetCursorPosition(0, 0);
  23.             Console.Write("[");
  24.             Console.BackgroundColor = ConsoleColor.Red;
  25.             Console.Write(bar);
  26.             bar = "";
  27.             Console.BackgroundColor = defaultColor;
  28.             for (int i = 0; i <maxvalue/10- ((value / 10) - 1); i++)
  29.             {
  30.                 bar += '_';
  31.             }
  32.             Console.Write(bar);
  33.             Console.Write("]");
  34.         }
  35.         static void Main(string[] args)
  36.         {
  37.             double health=0 ;
  38.             double maxhealth=100;
  39.             Console.WriteLine("Введите процент health");
  40.             health=Convert.ToDouble(Console.ReadLine());
  41.             Console.Clear();
  42.             Drawbar(health, maxhealth);          
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment