SpaceBattleSimulation { public static void engagement(Ship enemy, Ship friend){ while(!enemy.isDestroyed && friend.isDestroyed == false){ int friendAtkVal = friend.attack((Class<Ship>) enemy.getClass()); enemy.attacked(friendAtkVal); int enemyAttackVal = enemy.attack((Class<Ship>) friend.getClass()); friend.attacked(enemyAttackVal); } }  static void main(String[] args); static void engagement(Ship enemy, Ship friend);  }
@Test public void dreadnaughtTest() { SpaceBattleSimulation sim = new SpaceBattleSimulation(); SpaceBattleSimulation.Bomber friend = sim.new Bomber(); SpaceBattleSimulation.PatrolVessel enemy = sim.new PatrolVessel(); SpaceBattleSimulation.engagement(enemy, friend); System.out.println("Dreadnaught: " + friend.isDestroyed); System.out.println("Patrol Vessel: " + enemy.isDestroyed); }
@Test public void fighterAttacksBomber(){ SpaceBattleSimulation sim = new SpaceBattleSimulation(); Fighter fighter = sim.new Fighter(); Bomber bomber = sim.new Bomber(); int startingHealth = fighter.getHp(); SpaceBattleSimulation.engagement(fighter, bomber); int endingHealth = fighter.getHp(); Assert.assertEquals(200, (startingHealth - endingHealth)); }
@Test public void bomberAttacksDreadnaught(){ SpaceBattleSimulation sim = new SpaceBattleSimulation(); Bomber bomber = sim.new Bomber(); Dreadnaught dread = sim.new Dreadnaught(); int startingHealth = dread.getHp(); SpaceBattleSimulation.engagement(bomber, dread); int endingHealth = dread.getHp(); Assert.assertEquals(600000, (startingHealth - endingHealth)); }
@Test public void fighterAttacksDreadnaught(){ SpaceBattleSimulation sim = new SpaceBattleSimulation(); Fighter fighter = sim.new Fighter(); Dreadnaught dread = sim.new Dreadnaught(); int startingHealth = dread.getHp(); SpaceBattleSimulation.engagement(fighter, dread); int endingHealth = dread.getHp(); Assert.assertEquals(600, (startingHealth - endingHealth)); }
@Test public void bomberAttacksCruiser(){ SpaceBattleSimulation sim = new SpaceBattleSimulation(); Bomber bomber = sim.new Bomber(); Cruiser cruiser = sim.new Cruiser(); int startingHealth = cruiser.getHp(); SpaceBattleSimulation.engagement(bomber, cruiser); int endingHealth = cruiser.getHp(); Assert.assertEquals(300000, (startingHealth - endingHealth)); }
@Test public void fighterAttacksCruiser(){ SpaceBattleSimulation sim = new SpaceBattleSimulation(); Fighter fighter = sim.new Fighter(); Cruiser cruiser = sim.new Cruiser(); int startingHealth = cruiser.getHp(); SpaceBattleSimulation.engagement(fighter, cruiser); int endingHealth = cruiser.getHp(); Assert.assertEquals(600, (startingHealth - endingHealth)); }
@Test public void bomberAttacksDestroyer(){ SpaceBattleSimulation sim = new SpaceBattleSimulation(); Bomber bomber = sim.new Bomber(); Destroyer destroyer = sim.new Destroyer(); int startingHealth = destroyer.getHp(); SpaceBattleSimulation.engagement(bomber, destroyer); int endingHealth = destroyer.getHp(); Assert.assertEquals(100000, (startingHealth - endingHealth)); }
@Test public void bomberAttacksPatrolVessel(){ SpaceBattleSimulation sim = new SpaceBattleSimulation(); Bomber bomber = sim.new Bomber(); PatrolVessel patrol = sim.new PatrolVessel(); int startingHealth = patrol.getHp(); SpaceBattleSimulation.engagement(bomber, patrol); int endingHealth = patrol.getHp(); Assert.assertEquals(200, (startingHealth - endingHealth)); }
@Test public void fighterAttacksPatrolVessel(){ SpaceBattleSimulation sim = new SpaceBattleSimulation(); Fighter fighter = sim.new Fighter(); PatrolVessel patrol = sim.new PatrolVessel(); int startingHealth = patrol.getHp(); SpaceBattleSimulation.engagement(fighter, patrol); int endingHealth = patrol.getHp(); Assert.assertEquals(200, (startingHealth - endingHealth)); }