From 1a0709253e64fe4e828a29e332172cd8ed37edce Mon Sep 17 00:00:00 2001 From: fdai7920 Date: Fri, 2 Feb 2024 15:14:04 +0100 Subject: [PATCH] Relationship Player_PlayerService --- src/main/java/de/hsfulda/onses/models/Player.java | 10 ++++++++++ .../java/de/hsfulda/onses/services/PlayerService.java | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/hsfulda/onses/models/Player.java b/src/main/java/de/hsfulda/onses/models/Player.java index 3f92e8d..88ce707 100644 --- a/src/main/java/de/hsfulda/onses/models/Player.java +++ b/src/main/java/de/hsfulda/onses/models/Player.java @@ -7,6 +7,7 @@ import java.util.ArrayList; public class Player { private PlayerService playerService; + private Game game; private final ArrayList playerDeck = new ArrayList<>(); public ArrayList getPlayerDeck() { @@ -27,4 +28,13 @@ public class Player { this.playerService = playerService; return this; } + + public Game getGame() { + return game; + } + + public Player setGame(Game game) { + this.game = game; + return this; + } } diff --git a/src/main/java/de/hsfulda/onses/services/PlayerService.java b/src/main/java/de/hsfulda/onses/services/PlayerService.java index 61c5eff..a9f651e 100644 --- a/src/main/java/de/hsfulda/onses/services/PlayerService.java +++ b/src/main/java/de/hsfulda/onses/services/PlayerService.java @@ -44,7 +44,7 @@ public class PlayerService { public PlayerService() { - addPlayerToList(new Player().setPlayerService(this)); - addPlayerToList(new Player().setPlayerService(this)); + addPlayerToList(new Player().setPlayerService(this).setGame(this.game)); + addPlayerToList(new Player().setPlayerService(this).setGame(this.game)); } }