Пример #1
0
 public void move(Warrior warrior)
 {
     if (warrior.HP > 70)
     {
         warrior.setState(new NormalState());
     }
     else if (warrior.HP <= 30)
     {
         warrior.setState(new FuryState());
         warrior.move();
     }
     else
     {
         Console.WriteLine("HP" + warrior.HP + ", 背水一戰 傷害增加30%");
     }
 }
Пример #2
0
 public void move(Warrior warrior)
 {
     if (warrior.HP > 70)
     {
         Console.WriteLine("HP" + warrior.HP + ", 一般狀態");
     }
     else
     {
         warrior.setState(new DesperateState());
         warrior.move();
     }
 }
Пример #3
0
 public void move(Warrior warrior)
 {
     if (warrior.HP > 70)
     {
         warrior.setState(new NormalState());
         warrior.move();
     }
     else if (warrior.HP == 0)
     {
         warrior.setState(new UnableState());
         warrior.move();
     }
     else if (warrior.HP > 30)
     {
         warrior.setState(new DesperateState());
         warrior.move();
     }
     else
     {
         Console.WriteLine("HP" + warrior.HP + ", 狂怒狀態 傷害增加50% 防禦增加50%");
     }
 }
Пример #4
0
        public static void Main(string[] args)
        {
            Warrior warrior = new Warrior();

            warrior.setState(new NormalState());
            warrior.move();

            warrior.getDamage(30);
            warrior.move();
            warrior.getDamage(50);
            warrior.move();

            warrior.heal(120);
            warrior.move();

            warrior.getDamage(110);
            warrior.move();
        }