From 1bed4a77a54f6662ecfe208ca6102ff011b792fa Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Tue, 3 May 2011 19:06:14 +0200 Subject: Implemented new StoneSet split behavior git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@87 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/model/StoneSet.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') 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, Sizeable { * @return A pair of StoneSets, one for each split part */ public Pair splitAt(int position) { - // Exception in case of wrong index - if (position == 0 || position == stones.size()) { - throw new IndexOutOfBoundsException(); + if (position == 0) { + return new Pair(null, this); + } else if (position == stones.size()) { + return new Pair(this, null); } StoneSet firstSet = new StoneSet(stones.subList(0, position)); StoneSet secondSet = new StoneSet(stones.subList(position, -- cgit v1.2.3