diff options
author | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-05-03 19:06:14 +0200 |
---|---|---|
committer | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-05-03 19:06:14 +0200 |
commit | 1bed4a77a54f6662ecfe208ca6102ff011b792fa (patch) | |
tree | d6f95a19f00e3437fe209914be64279b9624504f | |
parent | a39b31d893dc28b5e3e8d282ee421c10e9a70f06 (diff) | |
download | JRummikub-1bed4a77a54f6662ecfe208ca6102ff011b792fa.tar JRummikub-1bed4a77a54f6662ecfe208ca6102ff011b792fa.zip |
Implemented new StoneSet split behavior
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@87 72836036-5685-4462-b002-a69064685172
-rw-r--r-- | src/jrummikub/model/StoneSet.java | 7 |
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, |