package lect2_hierarchy; import utils.DomainConstraint; import utils.NotPossibleException; /** * @overview An Armor Piercing (AP) projectile is a sub-class of Projectile * that represents a special attack that can ignore armor value * and inflict full damage to the targeted enemy tank in the game * * @abstract_property * P_Projectile /\ * mutable(radius) = false /\ optional(radius) = false /\ max(radius) = 1 * * @author namhv */ public class ProjectileAP extends Projectile { private static final int MAX_RADIUS = 1; public ProjectileAP(int d, int ang, int r) throws NotPossibleException { super(d, ang, r); } @Override public String toString() { return "AP Projectile: <" + getDamage() + "," + getAngle() + "," + getRadius() + ">"; } @Override @DomainConstraint(type="Integer", max=MAX_RADIUS, optional=false) protected boolean validateRadius(int r) { if (r > MAX_RADIUS) { return false; } return true; } }