NS2A2

Bài 2.2 C#

Dec 25th, 2020 (edited)
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.20 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 Test
  8. {
  9.     class Kinght
  10.     {
  11.         public int HP { get; set; }
  12.         public string Name { get; set; }
  13.         public int MP { get; set; }
  14.         public int Heal = 30;
  15.         public void InputInfo()
  16.         {
  17.             Name = Console.ReadLine();
  18.             HP = int.Parse(Console.ReadLine());
  19.             MP = int.Parse(Console.ReadLine());
  20.         }
  21.         public bool CheckMP()
  22.         {
  23.             return MP >= 50;
  24.         }
  25.         public void UseSkill()
  26.         {
  27.             if (MP >= 50)
  28.             {
  29.                 MP -= 50;
  30.                 HP += Heal;
  31.             }
  32.             ShowInfo();
  33.         }
  34.         public void ShowInfo()
  35.         {
  36.             Console.WriteLine("HP: " + HP);
  37.             Console.WriteLine("MP: " + MP);
  38.         }
  39.     }
  40.     class RunMain
  41.     {
  42.         static void Main(string[] args)
  43.         {
  44.             Kinght a = new Kinght();
  45.             a.InputInfo();
  46.             while (a.CheckMP())
  47.             {
  48.                 a.UseSkill();
  49.             }
  50.             Console.ReadKey();
  51.         }
  52.     }
  53. }
  54.  
Add Comment
Please, Sign In to add comment