class SpaceBattleSimulation {

	public static void engagement(Ship enemy, Ship friend){
		while(!enemy.isDestroyed && friend.isDestroyed == false){
			//Friendly attacks enemy
			int friendAtkVal = friend.attack((Class<Ship>) enemy.getClass());
			enemy.attacked(friendAtkVal);
			
			//Enemy attacks Friendly
			int enemyAttackVal = enemy.attack((Class<Ship>) friend.getClass());
			friend.attacked(enemyAttackVal);
			
		}
	}

}

class SpaceBattleSimulationTest {

	@Test
	public void fighterAttacksCruiser(){

		SpaceBattleSimulation sim = new SpaceBattleSimulation();
		//One fighter should do 200 dmg per round.
		//A Cruiser will do 1,000 dmg against a fighter.
		//A Cruiser with full health will destroy a fighter in 3 rounds
		
		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));
		
	}

}