package lect2_hierarchy; import utils.DomainConstraint; import utils.NotPossibleException; /** * @overview A High Explosive (HE) projectile is a sub-class of Projectile * that represents a special attack that can damage multiple enemies * in area-of-effect radius (in terms of cells) in the game * * @abstract_property * P_Projectile /\ * mutable(radius) = false /\ optional(radius) = false /\ min(radius) = 2 /\ max(radius) = 5 * * @author namhv */ public class ProjectileHE extends Projectile { private static final int MIN_RADIUS = 2; private static final int MAX_RADIUS = 5; public ProjectileHE(int d, int ang, int r) throws NotPossibleException { super(d, ang, r); } @Override public String toString() { return "HE Projectile: <" + getDamage() + "," + getAngle() + "," + getRadius() + ">"; } @Override @DomainConstraint(type="Integer", min=MIN_RADIUS, max=MAX_RADIUS, optional=false) protected boolean validateRadius(int r) { if (r < MIN_RADIUS || r > MAX_RADIUS) { return false; } return true; } }