AlexRaynor

4.2 UIElement

Sep 22nd, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp18
  8. {
  9.     class Program
  10.     {
  11.  
  12.         static int Health = 10;
  13.  
  14.         static void Main(string[] args)
  15.         {
  16.              Health = 4;
  17.              Console.Clear();
  18.              DrawBarData();
  19.  
  20.         }
  21.  
  22.         static void DrawBarData()
  23.         {
  24.             Console.Write("Health ");
  25.             Console.Write("[" + GenerateBar(Health) + "]");
  26.             Console.WriteLine();
  27.         }
  28.  
  29.         static string GenerateBar(int charsQuantity, char container = '#')
  30.         {
  31.             string bar = "";
  32.             for (int i = 0; i < 10; i++)
  33.             {
  34.                 if (i > charsQuantity - 1)
  35.                 {
  36.                     bar += " ";
  37.                 }
  38.                 else
  39.                 {
  40.                     bar += container;
  41.                 }
  42.             }
  43.             return bar;
  44.         }
  45.  
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment