package project;

public class FlyingZombie extends Monster implements flyable {

  private boolean print;
  
  public FlyingZombie (Player1 player, int x, int y) { 
    super( x, y, FlyingZombieAttack, FlyingZombieHealth); 
    target = player;
	text = player.text;
	print = false;
  } //constructor FlyingZombie
  
  public void update() { if (SameLocation(target) && Alive && target.Alive) Encounter(); } //method update
  
  public void beAttacked(Attackable a) {
     try {
	   healthDw(a.getAttackPower());
	 } catch (NoHealthException exception) {
	  target.inBattle = false;
	  text.println ("The zombie crashed into the woods..");
	 } //catch
  } //method beAttacked
  
  public void healthDw(int x) throws NoHealthException {
    if(health-x > 0)
  	  health = health - x;
  	else {
  	   Disable();
  	   throw new NoHealthException();
  	} //else
  } //method healthDw
  
  public void Encounter() {
    if (!print) {
      text.println ("A flying hairy creature landed in front of you...");
	  text.println ("The Creature: hahaha.....");
	  getEnemyInfo();
	  text.println ("<<<Press Attack to engage in Battle>>>");
	  print = true;
	} //if
	target.inBattle = true;
	target.get(this);
  } //method Encounter
  
  public void getEnemyInfo() { 
    text.println ("<Enemy Type>: FlyingZombie");
	text.println ("<AttackPower>: " + FlyingZombieAttack);
	text.println ("<Health>: " + FlyingZombieHealth + "units");
  } //method getEnemyInfo
  
  public void fly() { text.println ("and it fleed high into the air..."); }
  
  public void AttackIntro() { 
	text.println ("It bit you neck.."); 
    fly();
  } 

} //class FlyingZombie