Monster.java



/** モンスターを表すクラス */
public class Monster extends Creature implements Attacker {

  /** 魔法力を表す数値 */
    public int magicalPoint;

  /** 他の生命体を攻撃する */
    public void attack( Life life ) {
        int point = life.getLifePoint();
        int damage = (int)( magicalPoint * Math.random() );
        life.setLifePoint( point - damage );
    }

  /** コンストラクタ */
    public Monster( String name, int lifePoint, int magicalPoint ) {
        super( name, lifePoint );
        this.magicalPoint = magicalPoint;
    }
}