StoneSet fertig und getestet :-)

git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@47 72836036-5685-4462-b002-a69064685172
This commit is contained in:
Ida Massow 2011-05-01 01:23:15 +02:00
parent 027656acf7
commit 22b163ca9c
2 changed files with 12 additions and 10 deletions

View file

@ -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() {

View file

@ -93,14 +93,14 @@ public class StoneSetTest {
}
// invalid Split
@Test(expected = AssertionError.class)
@Test(expected = IndexOutOfBoundsException.class)
public void testSplitInvalidLow() {
StoneSet testSet = createTestSet();
testSet.splitAt(0);
}
@Test(expected = AssertionError.class)
@Test(expected = IndexOutOfBoundsException.class)
public void testSplitInvalidHigh() {
StoneSet testSet = createTestSet();
testSet.splitAt(3);