GPbl3YH

CSLight #20

Jan 25th, 2021 (edited)
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.41 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 CSLight
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.WriteLine("Введите координату x:");
  14.             int posX = Convert.ToInt32(Console.ReadLine());
  15.             Console.WriteLine("Введите координату y:");
  16.             int posY = Convert.ToInt32(Console.ReadLine());
  17.             Console.WriteLine("Введите заполненность бара (от 0 до 10):");
  18.             int fullNess = Convert.ToInt32(Console.ReadLine());
  19.  
  20.             if (fullNess < 0 || fullNess > 10)
  21.             {
  22.                 DrawHealthBar(posX, posY);
  23.             }
  24.             else
  25.             {
  26.                 DrawHealthBar(posX, posY, fullNess);
  27.             }
  28.  
  29.             Console.ReadKey();
  30.         }
  31.  
  32.         static void DrawHealthBar(int posX, int posY, int fullNess = 10)
  33.         {
  34.             Console.SetCursorPosition(posX, posY);
  35.             Console.Write("[");
  36.  
  37.             int maxHealth = 10;
  38.  
  39.             for (int x = 0; x < fullNess; x++)
  40.             {
  41.                 Console.Write("#");
  42.             }
  43.  
  44.             for (int x = 0; x < maxHealth - fullNess; x++)
  45.             {
  46.                 Console.Write("_");
  47.             }
  48.  
  49.             Console.Write("]");
  50.         }
  51.     }
  52. }
Add Comment
Please, Sign In to add comment