class SpaceBattleSimulation {

	protected static boolean battle(List<Ship> friendly, List<Ship> enemy){
		
		Ship friendlyShip = friendly.remove(0);
		Ship enemyShip = enemy.remove(0);
		
		int friendlyFleetSize = friendly.size() + 1;
		int enemyFleetSize = enemy.size() + 1;
		
		while(friendlyFleetSize > 0 && enemyFleetSize > 0){
			engagement(enemyShip, friendlyShip);

			if(friendlyShip.isDestroyed){
				if(friendly.size() > 0){
					friendlyShip = friendly.remove(0);
				}
				--friendlyFleetSize;
			}
			
			if(enemyShip.isDestroyed){
				if(enemy.size() > 0){
					enemyShip = enemy.remove(0);
				}
				--enemyFleetSize;
			}
			
		}

        return friendlyFleetSize > 0 && enemyFleetSize == 0;
			
		
	}

}