diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-05-18 17:01:10 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-05-18 17:01:10 +0200 |
commit | b5397d5aa7f01d557a469ca0d70f3b33e1fe2c60 (patch) | |
tree | 899de9a3f0e71718ecf8f6018e2b8c347b3b93df /src/jrummikub/model | |
parent | 5169f31af06926f4c268062791f648f1fdd91656 (diff) | |
download | JRummikub-b5397d5aa7f01d557a469ca0d70f3b33e1fe2c60.tar JRummikub-b5397d5aa7f01d557a469ca0d70f3b33e1fe2c60.zip |
Move some static player data to a player settings class
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@252 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/model')
-rw-r--r-- | src/jrummikub/model/IPlayer.java | 17 | ||||
-rw-r--r-- | src/jrummikub/model/Player.java | 30 | ||||
-rw-r--r-- | src/jrummikub/model/PlayerSettings.java | 42 | ||||
-rw-r--r-- | src/jrummikub/model/RoundState.java | 8 |
4 files changed, 62 insertions, 35 deletions
diff --git a/src/jrummikub/model/IPlayer.java b/src/jrummikub/model/IPlayer.java index ebe77fa..1ae6f12 100644 --- a/src/jrummikub/model/IPlayer.java +++ b/src/jrummikub/model/IPlayer.java @@ -1,7 +1,5 @@ package jrummikub.model; -import java.awt.Color; - /** * Interface for {@link Player} model */ @@ -15,19 +13,16 @@ public interface IPlayer { public IHand getHand(); /** - * Return the player's color + * Has the player laid out yet? * - * @return the player's color + * @return if the player has laid out */ - public Color getColor(); + public boolean getLaidOut(); /** - * Return the name of the player + * Returns the player settings * - * @return the player's name + * @return the player settings */ - public String getName(); - - boolean getLaidOut(); - + public PlayerSettings getPlayerSettings(); }
\ No newline at end of file diff --git a/src/jrummikub/model/Player.java b/src/jrummikub/model/Player.java index 9444b5a..f482f28 100644 --- a/src/jrummikub/model/Player.java +++ b/src/jrummikub/model/Player.java @@ -1,46 +1,36 @@ package jrummikub.model; -import java.awt.Color; - /** Class managing player data. No methods in release 1 */ public class Player implements IPlayer { - + private PlayerSettings settings; private IHand hand; - private String name; - private Color color; private boolean laidOut; /** * Create a new player with a given name and color * - * @param name - * player name - * @param color - * player's color + * @param settings + * the player settings */ - public Player(String name, Color color) { + public Player(PlayerSettings settings) { + this.settings = settings; + hand = new Hand(); - this.name = name; - this.color = color; + laidOut = false; } @Override public IHand getHand() { return hand; } - + @Override public boolean getLaidOut() { return laidOut; } @Override - public Color getColor() { - return color; - } - - @Override - public String getName() { - return name; + public PlayerSettings getPlayerSettings() { + return settings; } } diff --git a/src/jrummikub/model/PlayerSettings.java b/src/jrummikub/model/PlayerSettings.java new file mode 100644 index 0000000..87c2a27 --- /dev/null +++ b/src/jrummikub/model/PlayerSettings.java @@ -0,0 +1,42 @@ +package jrummikub.model; + +import java.awt.Color; + +/** + * The settings of a player + */ +public class PlayerSettings { + private String name; + private Color color; + + /** + * Create a new human player + * + * @param name + * the player's name + * @param color + * the player's color + */ + public PlayerSettings(String name, Color color) { + this.name = name; + this.color = color; + } + + /** + * Returns the player's color + * + * @return the color + */ + public Color getColor() { + return color; + } + + /** + * Returns the player's name + * + * @return the name + */ + public String getName() { + return name; + } +} diff --git a/src/jrummikub/model/RoundState.java b/src/jrummikub/model/RoundState.java index 4a27d2d..b566fdf 100644 --- a/src/jrummikub/model/RoundState.java +++ b/src/jrummikub/model/RoundState.java @@ -24,10 +24,10 @@ public class RoundState implements IRoundState { table = new Table(); players = new ArrayList<Player>(); - players.add(new Player("Ida", Color.RED)); - players.add(new Player("Matthias", Color.YELLOW)); - players.add(new Player("Jannis", Color.GREEN)); - players.add(new Player("Bennet", Color.BLACK)); + players.add(new Player(new PlayerSettings("Ida", Color.RED))); + players.add(new Player(new PlayerSettings("Matthias", Color.YELLOW))); + players.add(new Player(new PlayerSettings("Jannis", Color.GREEN))); + players.add(new Player(new PlayerSettings("Bennet", Color.BLACK))); activePlayer = 0; gameHeap = new StoneHeap(); } |