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:
parent
46f75188cb
commit
562a478ef8
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user