예제 #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();
        }