package lect2_hierarchy; import utils.NotPossibleException; /** * @overview * A program that demonstrate how to use {@link Projectile, HE_Projectile, AP_Projectile} * * @author namhv */ public class ProjectileTestApp { /** * The main method * @effects
     *      create {@link Projectile, HE_Projectile, AP_Projectile} pt, pt_he, pt_ap objects
     *      display an error message if failed
     *      
*/ public static void main(String[] args) { // create a new Projectile Projectile pt1 = null; try { pt1 = new Projectile(5, 0, 1); // display the projectile object System.out.println("Created: " + pt1); } catch (NotPossibleException e) { System.err.println("-> Failed to create projectile"); e.printStackTrace(); } // create a new Projectile Projectile pt2 = null; try { pt1 = new Projectile(10, 0, 0); // display the projectile object System.out.println("Created: " + pt2); } catch (NotPossibleException e) { System.err.println("-> Failed to create projectile"); e.printStackTrace(); } // create a new HE Projectile ProjectileHE pt_he1 = null; try { pt_he1 = new ProjectileHE(10, 45, 2); // display the projectile HE object System.out.println("Created: " + pt_he1); } catch (NotPossibleException e) { System.err.println("-> Failed to create HE projectile"); e.printStackTrace(); } // create a new HE Projectile ProjectileHE pt_he2 = null; try { pt_he2 = new ProjectileHE(10, 90, 6); // display the projectile HE object System.out.println("Created: " + pt_he2); } catch (NotPossibleException e) { System.err.println("-> Failed to create HE projectile"); e.printStackTrace(); } // create a new AP Projectile ProjectileAP pt_ap1 = null; try { pt_ap1 = new ProjectileAP(5, 135, 1); // display the projectile AP object System.out.println("Created: " + pt_ap1); } catch (NotPossibleException e) { System.err.println("-> Failed to create AP projectile"); e.printStackTrace(); } } }