add: Thread protection Player.java

This commit is contained in:
ole 2024-11-30 17:07:11 +01:00
parent 058d069ff2
commit 22950cd155
1 changed files with 2 additions and 11 deletions

View File

@ -11,18 +11,9 @@ public abstract class Player {
this.board = new Board(size);
}
public synchronized void receiveShoot(Point point) {
HitResponse hitResponse = board.getHitResponsOnPoint(point);
if (!(hitResponse == null)){
enemy.receiveHit(hitResponse);
} else {
enemy.receiveHit(this.board.hit(point));
}
}
public abstract void receiveShoot(Point point);
public synchronized void receiveHit(HitResponse hitResponse) {
enemy.board.addHits(hitResponse);
}
public abstract void receiveHit(HitResponse hitResponse);
public void click(Point point) {