Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace Task2
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             Console.WriteLine("Сколько % жизней у вашего героя?");
  13.             int health = Convert.ToInt32(Console.ReadLine());
  14.  
  15.             DrawHealtBar(health);
  16.             Console.ReadKey();
  17.         }
  18.  
  19.         static void DrawHealtBar(int health, char fillSymbol = '#', char voidSymbol = '_', int left = 55, int top = 0)
  20.         {
  21.             Console.SetCursorPosition(left, top);
  22.  
  23.             char[] simbols = new char[10];
  24.  
  25.             for (int i = 0; i < simbols.Length; i++)
  26.             {
  27.                 simbols[i] = voidSymbol;
  28.             }
  29.  
  30.             if(health <= 100)
  31.             {
  32.                 for (int i = 0; i < health / 10; i++)
  33.                 {
  34.                     simbols[i] = fillSymbol;
  35.                 }
  36.  
  37.                 Console.WriteLine(simbols);
  38.             }
  39.             else
  40.             {
  41.                 Console.WriteLine("Это не проценты!");
  42.             }
  43.  
  44.             Console.SetCursorPosition(0, 2);
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement