Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Runtime.InteropServices;
- namespace FifthProject
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Введите X координату");
- int x = ConvertToInt(Console.ReadLine());
- Console.WriteLine("Введите Y координату");
- int y = ConvertToInt(Console.ReadLine());
- Console.WriteLine("Введите процент заполнения бара");
- int health = ConvertToInt(Console.ReadLine());
- DrawHealthBar(x, y, health);
- }
- static void DrawHealthBar(int x, int y, int health)
- {
- Console.SetCursorPosition(x, y);
- Console.Write("[");
- for (int i = 0; i < health/10; i++)
- {
- Console.Write("#");
- }
- for (int i = 0; i < 10 - health/10; i++)
- {
- Console.Write(" ");
- }
- Console.Write("]");
- }
- static int ConvertToInt(string input)
- {
- int output;
- bool enterIsCorrect = int.TryParse(input, out output);
- do
- {
- if (!enterIsCorrect)
- {
- Console.WriteLine("Ложное значение.");
- }
- } while (!enterIsCorrect);
- return output;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement