diff --git a/Makefile b/Makefile index 8523c36..2b202b4 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,7 @@ LIBARIES= CLASSES=\ src/game/Main.java \ src/game/Game.java \ +src/game/PlayerObject.java \ src/player/Player.java \ src/player/Player1.java \ src/player/Player2.java diff --git a/src/game/Game.java b/src/game/Game.java index c4f80f3..85d2973 100644 --- a/src/game/Game.java +++ b/src/game/Game.java @@ -22,17 +22,17 @@ public class Game { /** * Player One */ - private final Player p1; + private final PlayerObject p1; /** * Player Two */ - private final Player p2; + private final PlayerObject p2; /** * Player who made the last move. */ - private Player lastPlayer; + private PlayerObject lastPlayer; /** * The game's board. @@ -56,8 +56,8 @@ public class Game { * @param p2 Player Two */ public Game(Player p1, Player p2) { - this.p1 = p1; - this.p2 = p2; + this.p1 = new PlayerObject(p1); + this.p2 = new PlayerObject(p2); this.board = new int [GAME_COLUMNS][GAME_ROWS]; this.gameOn = false; } diff --git a/src/game/PlayerObject.java b/src/game/PlayerObject.java new file mode 100644 index 0000000..fdd280a --- /dev/null +++ b/src/game/PlayerObject.java @@ -0,0 +1,40 @@ +package player; + +/** + * Wrapper for the player. + * This is a wrapper for a player. This guarantees, that no + * player will change his Symbol, nor his id. + */ +public class PlayerObject { + + private final Player p; + private final int id; + private String sym; + + /** + * Wraps a player. + * + * @param id The players id. + * @param p The player himself. + */ + public PlayerObject(int id, Player p) { + this.p = p; + this.id = id; + } + + public void setSymbol(String sym) { + this.sym = sym; + } + + public String getSymbol() { + return this.sym; + } + + public Player getP() { + return this.p; + } + + public int getID() { + return this.id; + } +}