summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/model
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/model')
-rw-r--r--src/jrummikub/model/StoneSet.java7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/jrummikub/model/StoneSet.java b/src/jrummikub/model/StoneSet.java
index 6081730..98fa325 100644
--- a/src/jrummikub/model/StoneSet.java
+++ b/src/jrummikub/model/StoneSet.java
@@ -132,9 +132,10 @@ public class StoneSet implements Iterable<Stone>, Sizeable {
* @return A pair of StoneSets, one for each split part
*/
public Pair<StoneSet, StoneSet> splitAt(int position) {
- // Exception in case of wrong index
- if (position == 0 || position == stones.size()) {
- throw new IndexOutOfBoundsException();
+ if (position == 0) {
+ return new Pair<StoneSet, StoneSet>(null, this);
+ } else if (position == stones.size()) {
+ return new Pair<StoneSet, StoneSet>(this, null);
}
StoneSet firstSet = new StoneSet(stones.subList(0, position));
StoneSet secondSet = new StoneSet(stones.subList(position,