From 0ef783407075008514b9e3eb9b32ea67501e4206 Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Sat, 30 Apr 2011 15:45:11 +0200 Subject: =?UTF-8?q?Arrays=20zu=20Listen=20ge=C3=A4ndert,=20StoneTray=20Kla?= =?UTF-8?q?sse=20mit=20Sizeable=20Interface=20angelegt,=20Testklassen=20er?= =?UTF-8?q?zeugt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@26 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/model/GameState.java | 2 +- src/jrummikub/model/Hand.java | 26 +------------------------- src/jrummikub/model/Sizeable.java | 9 +++++++++ src/jrummikub/model/StoneSet.java | 6 ++++-- src/jrummikub/model/StoneTray.java | 31 +++++++++++++++++++++++++++++++ src/jrummikub/model/Table.java | 28 ++-------------------------- src/jrummikub/util/Pair.java | 24 ++++++++++++++++++++++++ test/jrummikub/model/HandTest.java | 5 ----- test/jrummikub/model/PlayerTest.java | 5 ----- test/jrummikub/model/StoneSetTest.java | 6 ++++++ test/jrummikub/model/StoneTrayTest.java | 6 ++++++ 11 files changed, 84 insertions(+), 64 deletions(-) create mode 100644 src/jrummikub/model/Sizeable.java create mode 100644 src/jrummikub/model/StoneTray.java create mode 100644 src/jrummikub/util/Pair.java delete mode 100644 test/jrummikub/model/HandTest.java delete mode 100644 test/jrummikub/model/PlayerTest.java create mode 100644 test/jrummikub/model/StoneSetTest.java create mode 100644 test/jrummikub/model/StoneTrayTest.java diff --git a/src/jrummikub/model/GameState.java b/src/jrummikub/model/GameState.java index ce81ece..d5c12ba 100644 --- a/src/jrummikub/model/GameState.java +++ b/src/jrummikub/model/GameState.java @@ -3,7 +3,7 @@ package jrummikub.model; /** Class managing the overall and momentary GameState */ public class GameState { private Table table; - private Player[] players; + private List players; private int activePlayer; private StoneHeap gameHeap; diff --git a/src/jrummikub/model/Hand.java b/src/jrummikub/model/Hand.java index 9437b04..033dfa1 100644 --- a/src/jrummikub/model/Hand.java +++ b/src/jrummikub/model/Hand.java @@ -1,30 +1,6 @@ package jrummikub.model; /** Class managing a {@link Player}'s {@link Stone}s */ -public class Hand { - private Stone[] stones; - private Position[] position; - - /** - * Removes {@link Stone} from Hand and returns it - * - * @param position - * position of {@link Stone} that will be removed - */ - public Stone pickUp(Position position) { - - } - - /** - * Adds {@link Stone} to the Hand - * - * @param stone - * {@link Stone} to add to Hand - * @param position - * {@link Position} to put the {@link Stone} - */ - public void drop(Stone stone, Position position) { - - } +public class Hand extends StoneTray { } diff --git a/src/jrummikub/model/Sizeable.java b/src/jrummikub/model/Sizeable.java new file mode 100644 index 0000000..fa022cc --- /dev/null +++ b/src/jrummikub/model/Sizeable.java @@ -0,0 +1,9 @@ +package jrummikub.model; + +/** + * Objects that have a size + */ +public interface Sizeable { + public float getWidth(); + public float getHeight(); +} diff --git a/src/jrummikub/model/StoneSet.java b/src/jrummikub/model/StoneSet.java index 67ad795..706ed3b 100644 --- a/src/jrummikub/model/StoneSet.java +++ b/src/jrummikub/model/StoneSet.java @@ -1,8 +1,10 @@ package jrummikub.model; +import jrummikub.util.Pair; + /** Class managing {@link Stone}s joined together to form sets */ public class StoneSet { - private Stone[] stones; + private List stones; /** Test for rule conflict within the StoneSet */ public boolean isValid() { @@ -16,7 +18,7 @@ public class StoneSet { * @param position * Splitting {@link Position} */ - public StoneSet[] splitAt(int position) { + public Pair splitAt(int position) { } diff --git a/src/jrummikub/model/StoneTray.java b/src/jrummikub/model/StoneTray.java new file mode 100644 index 0000000..4a22870 --- /dev/null +++ b/src/jrummikub/model/StoneTray.java @@ -0,0 +1,31 @@ +package jrummikub.model; + +/** A StoneTray is a collection of positioned objects (for example {@link Stone}s or {@link StoneSet}s. */ +public abstract class StoneTray { + protected List objects; + protected List positions; + + /** + * Removes object from tray and returns it + * + * @param position + * position of the object that will be removed + */ + public E pickUp(Position position) { + + } + + + /** + * Adds object to the tray + * + * @param object + * object to add to Hand + * @param position + * {@link Position} to put the object + */ + public void drop(E object, Position position) { + + } + +} diff --git a/src/jrummikub/model/Table.java b/src/jrummikub/model/Table.java index 923a6a1..8a1b40f 100644 --- a/src/jrummikub/model/Table.java +++ b/src/jrummikub/model/Table.java @@ -2,9 +2,7 @@ package jrummikub.model; /** Class administering the {@link Stone}s on the game-Table */ -public class Table { - private StoneSet[] sets; - private Position[] positions; +public class Table extends StoneTray { // Constructor public Table gameTable = new Table(); @@ -15,17 +13,7 @@ public class Table { * @param position * {@link Position} of the selected {@link Stone} */ - public Stone pickUp(Position position) { - - } - - /** - * Removes a {@link StoneSet} from the Table and returns it - * - * @param position - * {@link Position} of the selected {@link StoneSet} - */ - public StoneSet pickUpSet(Position position) { + public Stone pickUpStone(Position position) { } @@ -41,18 +29,6 @@ public class Table { } - /** - * Adds {@link StoneSet} to Table - * - * @param position - * Specifies {@link Position} to put the {@link StoneSet} - * @param stones - * The {@link StoneSet} to add to the Table - */ - public void drop(Position position, StoneSet stones) { - - } - /** Tests the Table for rule conflicts by checking all the {@link StoneSets} */ public boolean isValid() { diff --git a/src/jrummikub/util/Pair.java b/src/jrummikub/util/Pair.java new file mode 100644 index 0000000..95af113 --- /dev/null +++ b/src/jrummikub/util/Pair.java @@ -0,0 +1,24 @@ +package jrummikub.util; + +/** + * A pair of objects + */ +public class Pair { + final T1 first; + final T2 second; + + public Pair(T1 first, T2 second) { + this.first = first; + this.second = second; + } + + public T1 getFirst() { + return first; + } + + public T2 getSecond() { + return second; + } + + +} diff --git a/test/jrummikub/model/HandTest.java b/test/jrummikub/model/HandTest.java deleted file mode 100644 index 012a56c..0000000 --- a/test/jrummikub/model/HandTest.java +++ /dev/null @@ -1,5 +0,0 @@ -package jrummikub.model; - -public class HandTest { - -} diff --git a/test/jrummikub/model/PlayerTest.java b/test/jrummikub/model/PlayerTest.java deleted file mode 100644 index 8e2e66b..0000000 --- a/test/jrummikub/model/PlayerTest.java +++ /dev/null @@ -1,5 +0,0 @@ -package jrummikub.model; - -public class PlayerTest { - -} diff --git a/test/jrummikub/model/StoneSetTest.java b/test/jrummikub/model/StoneSetTest.java new file mode 100644 index 0000000..fc7ebda --- /dev/null +++ b/test/jrummikub/model/StoneSetTest.java @@ -0,0 +1,6 @@ +package jrummikub.model; + + +public class StoneSetTest { + +} diff --git a/test/jrummikub/model/StoneTrayTest.java b/test/jrummikub/model/StoneTrayTest.java new file mode 100644 index 0000000..df9aaa9 --- /dev/null +++ b/test/jrummikub/model/StoneTrayTest.java @@ -0,0 +1,6 @@ +package jrummikub.model; + + +public class StoneTrayTest { + +} -- cgit v1.2.3