add ship reset position

This commit is contained in:
Luca Conte 2024-12-15 12:53:44 +01:00
parent 80b5d8e701
commit 256d769ccf
1 changed files with 4 additions and 1 deletions

View File

@ -51,7 +51,6 @@ public class Ship {
private String name;
private int hitsOnMe;
private boolean sunk;
private boolean isPlaced;
public Ship (int size, String name) {
this.size = size;
@ -63,6 +62,10 @@ public class Ship {
this.isPlaced = false;
}
public void resetPosition() {
this.position = null;
}
public boolean setPosition(Point pos, List<Ship> shipsList, int boardSize) {
// ueberpruefe boundaries
if (pos.getX() < 0 || pos.getY() < 0 || pos.getX() >= boardSize || pos.getY() >= boardSize) {