Advertisement
Briotar

Homework 4

May 11th, 2021
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Homework4
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int percentHealth;
  10.             int percentMana;
  11.  
  12.             Console.SetCursorPosition(0,20);
  13.             Console.Write("Введите процент здоровья - ");
  14.             percentHealth = Convert.ToInt32(Console.ReadLine());
  15.             Console.Write("Введите процент маны - ");
  16.             percentMana = Convert.ToInt32(Console.ReadLine());
  17.  
  18.             Console.SetCursorPosition(0, 0);
  19.             DrawBar(percentHealth, ConsoleColor.Red);
  20.             DrawBar(percentMana, ConsoleColor.Blue);
  21.         }
  22.  
  23.         static void DrawBar(int percent, ConsoleColor color)
  24.         {
  25.             ConsoleColor defaultColor = Console.BackgroundColor;
  26.  
  27.             Console.Write("[");
  28.             Console.BackgroundColor = color;
  29.             for (int i = 0; i < percent / 10; i++)
  30.             {
  31.                 Console.Write("#");
  32.             }
  33.             Console.BackgroundColor = defaultColor;
  34.             for (int i = percent / 10; i < 10; i++)
  35.             {
  36.                 Console.Write("_");
  37.             }
  38.             Console.Write("]\n");
  39.         }
  40.     }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement