summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/model
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/model')
-rw-r--r--src/jrummikub/model/StoneSet.java18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/jrummikub/model/StoneSet.java b/src/jrummikub/model/StoneSet.java
index f10eca0..09eecd5 100644
--- a/src/jrummikub/model/StoneSet.java
+++ b/src/jrummikub/model/StoneSet.java
@@ -91,14 +91,14 @@ public class StoneSet implements Iterable<Stone> {
* Splitting {@link Position}
*/
public Pair<StoneSet, StoneSet> splitAt(int position) {
- // Exception falls falscher index
+ // Exception in case of wrong index
if (position == 0 || position == stones.size()) {
-
- } else {
-
+ throw new IndexOutOfBoundsException();
}
- return null;
-
+ StoneSet firstSet = new StoneSet(stones.subList(0, position));
+ StoneSet secondSet = new StoneSet(stones.subList(position,
+ stones.size()));
+ return new Pair<StoneSet, StoneSet>(firstSet, secondSet);
}
/**
@@ -108,8 +108,10 @@ public class StoneSet implements Iterable<Stone> {
* StoneSet to be joined to active StoneSet
*/
public StoneSet join(StoneSet other) {
- return null;
-
+ List<Stone> joinedList = new ArrayList<Stone>();
+ joinedList.addAll(stones);
+ joinedList.addAll(other.stones);
+ return new StoneSet(joinedList);
}
public int size() {