summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/model
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-05-03 21:34:58 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-05-03 21:34:58 +0200
commit2aeedc62418ab7816887f20e4ccb461fe6a0fcc0 (patch)
tree5124dc93180bc57efe49353ebecd1aa3816fdbe2 /src/jrummikub/model
parent14bb9dd4c2dbe0bcab9d599773138b94b3a09181 (diff)
downloadJRummikub-2aeedc62418ab7816887f20e4ccb461fe6a0fcc0.tar
JRummikub-2aeedc62418ab7816887f20e4ccb461fe6a0fcc0.zip
Added toString method to StoneSet
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@97 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/model')
-rw-r--r--src/jrummikub/model/StoneSet.java33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/jrummikub/model/StoneSet.java b/src/jrummikub/model/StoneSet.java
index 98fa325..98a808e 100644
--- a/src/jrummikub/model/StoneSet.java
+++ b/src/jrummikub/model/StoneSet.java
@@ -40,8 +40,8 @@ public class StoneSet implements Iterable<Stone>, Sizeable {
}
/**
- * Test for rule conflict within the StoneSet and determine whether the set
- * is a group or a run
+ * Test for rule conflict within the StoneSet and determine whether the set is
+ * a group or a run
*
* @return GROUP or RUN for valid sets, INVALID otherwise
*/
@@ -62,8 +62,7 @@ public class StoneSet implements Iterable<Stone>, Sizeable {
return GROUP;
}
// is run
- if (stones.get(nonJoker1).getColor() == stones.get(nonJoker2)
- .getColor()) {
+ if (stones.get(nonJoker1).getColor() == stones.get(nonJoker2).getColor()) {
return isValidRun(nonJoker1) ? RUN : INVALID;
}
@@ -77,7 +76,7 @@ public class StoneSet implements Iterable<Stone>, Sizeable {
* Test for rule conflict within the StoneSet, assuming we have a run
*
* @param referencePosition
- * position of stone used as reference (any non-joker stone)
+ * position of stone used as reference (any non-joker stone)
*/
private boolean isValidRun(int referencePosition) {
StoneColor runColor = stones.get(referencePosition).getColor();
@@ -128,7 +127,7 @@ public class StoneSet implements Iterable<Stone>, Sizeable {
* Stone Sets
*
* @param position
- * Splitting {@link Position}
+ * Splitting {@link Position}
* @return A pair of StoneSets, one for each split part
*/
public Pair<StoneSet, StoneSet> splitAt(int position) {
@@ -138,8 +137,7 @@ public class StoneSet implements Iterable<Stone>, Sizeable {
return new Pair<StoneSet, StoneSet>(this, null);
}
StoneSet firstSet = new StoneSet(stones.subList(0, position));
- StoneSet secondSet = new StoneSet(stones.subList(position,
- stones.size()));
+ StoneSet secondSet = new StoneSet(stones.subList(position, stones.size()));
return new Pair<StoneSet, StoneSet>(firstSet, secondSet);
}
@@ -147,7 +145,7 @@ public class StoneSet implements Iterable<Stone>, Sizeable {
* Joins StoneSet to another StoneSet and returns the resulting new StoneSet
*
* @param other
- * StoneSet to be joined to active StoneSet
+ * StoneSet to be joined to active StoneSet
* @return the combined StoneSet
*/
public StoneSet join(StoneSet other) {
@@ -170,7 +168,7 @@ public class StoneSet implements Iterable<Stone>, Sizeable {
* Returns the i-th stone of the set (starting with 0)
*
* @param i
- * number of the stone to return
+ * number of the stone to return
* @return the i-th stone
*/
public Stone get(int i) {
@@ -212,4 +210,19 @@ public class StoneSet implements Iterable<Stone>, Sizeable {
return 1 + 2 * HORIZONTAL_BORDER;
}
+ @Override
+ public String toString() {
+ String ret = "StoneSet[";
+ boolean first = true;
+
+ for (Stone stone : stones) {
+ if (!first)
+ ret += ",";
+
+ ret += stone.toString();
+ first = false;
+ }
+
+ return ret + "]";
+ }
}