summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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 + "]";
+ }
}