added solution for exercise 9

added the models for the 3 remaining ship types
and implemented them in the SeaSynchronizer.java
also added the correct logic for the ships to be displayed correctly
This commit is contained in:
Hanno Fleischer hanno.fleischer@unibw.de
2024-10-02 20:56:05 +02:00
parent 46f75188cb
commit 562a478ef8
16 changed files with 900739 additions and 31 deletions

View File

@@ -182,35 +182,6 @@ private boolean checkMap(MapMessage msg, int from) {
}
}
}
/*int[][] tempMap = new int[mapWidth][mapHeight];
for (int[] row : tempMap)
Arrays.fill(row, 0);
msg.getShips().forEach(s -> {
int deltaX = s.getMaxX()-s.getMinX();
int deltaY = s.getMaxY()-s.getMinY();
int lastX = s.getX();
int lastY = s.getY();
tempMap[lastX][lastY] += 1;
for (int i = 0; i < deltaX-1; i++)
for (int j = 0; j < deltaY-1; j++) {
tempMap[lastX + (deltaX / Math.abs(deltaX))][lastY + (deltaY / Math.abs(deltaY))] += 1;
lastX = lastX + (deltaX / Math.abs(deltaX));
lastY = lastY + (deltaY / Math.abs(deltaY));
}
});
for (int[] row : tempMap){
for(int cell : row){
if (cell > 1){
LOGGER.log(Level.ERROR, "There are multiple ships on one position");
return false;
}
}
}*/
return true;
}