summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/model/StoneSet.java
diff options
context:
space:
mode:
authorJannis Harder <harder@informatik.uni-luebeck.de>2011-05-10 03:54:48 +0200
committerJannis Harder <harder@informatik.uni-luebeck.de>2011-05-10 03:54:48 +0200
commit3b49b2053e9f9d26b73db0ffc8380a60706ee095 (patch)
tree9678d5abb4af070bbf0fd89c684e91f5fd472c31 /src/jrummikub/model/StoneSet.java
parent4a860e53cf6f2f97f18785673399498609e6504b (diff)
downloadJRummikub-3b49b2053e9f9d26b73db0ffc8380a60706ee095.tar
JRummikub-3b49b2053e9f9d26b73db0ffc8380a60706ee095.zip
Added all missing comments
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@213 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/model/StoneSet.java')
-rw-r--r--src/jrummikub/model/StoneSet.java41
1 files changed, 31 insertions, 10 deletions
diff --git a/src/jrummikub/model/StoneSet.java b/src/jrummikub/model/StoneSet.java
index 3723e75..83ce767 100644
--- a/src/jrummikub/model/StoneSet.java
+++ b/src/jrummikub/model/StoneSet.java
@@ -18,16 +18,34 @@ public class StoneSet implements Iterable<Stone>, Sizeable {
static final float HORIZONTAL_BORDER = 0.125f;
private List<Stone> stones;
+ /**
+ * Create a new single stone stone set
+ *
+ * @param stone
+ * single stone of the set
+ */
public StoneSet(Stone stone) {
stones = Collections.singletonList(stone);
}
+ /**
+ * Create a stone set from a list of stones
+ *
+ * @param stones
+ * list of stones to build a set of
+ */
public StoneSet(List<Stone> stones) {
this.stones = new ArrayList<Stone>(stones);
}
+ /** Validity type of the set */
public enum Type {
- GROUP, RUN, INVALID
+ /** Set is a valid group */
+ GROUP,
+ /** Set is a valid run */
+ RUN,
+ /** Set is invalid */
+ INVALID
}
/**
@@ -40,8 +58,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,13 +80,15 @@ 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;
}
// is group
else {
- return isValidGroup(stones.get(nonJoker1).getValue()) ? GROUP : INVALID;
+ return isValidGroup(stones.get(nonJoker1).getValue()) ? GROUP
+ : INVALID;
}
}
@@ -76,7 +96,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();
@@ -130,7 +150,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) {
@@ -140,7 +160,8 @@ 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);
}
@@ -148,7 +169,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) {
@@ -171,7 +192,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) {