From 22b163ca9c31c750f4701f01c472ee04f8f2ed14 Mon Sep 17 00:00:00 2001 From: Ida Massow Date: Sun, 1 May 2011 01:23:15 +0200 Subject: StoneSet fertig und getestet :-) git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@47 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/model/StoneSet.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/jrummikub') 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 { * Splitting {@link Position} */ public Pair 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(firstSet, secondSet); } /** @@ -108,8 +108,10 @@ public class StoneSet implements Iterable { * StoneSet to be joined to active StoneSet */ public StoneSet join(StoneSet other) { - return null; - + List joinedList = new ArrayList(); + joinedList.addAll(stones); + joinedList.addAll(other.stones); + return new StoneSet(joinedList); } public int size() { -- cgit v1.2.3