Added toString method to StoneSet

git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@97 72836036-5685-4462-b002-a69064685172
This commit is contained in:
Matthias Schiffer 2011-05-03 21:34:58 +02:00
parent 14bb9dd4c2
commit 2aeedc6241

View file

@ -40,8 +40,8 @@ public class StoneSet implements Iterable<Stone>, Sizeable {
}
/**
* Test for rule conflict within the StoneSet and determine whether the set
* is a group or a run
* Test for rule conflict within the StoneSet and determine whether the set is
* a group or a run
*
* @return GROUP or RUN for valid sets, INVALID otherwise
*/
@ -62,8 +62,7 @@ public class StoneSet implements Iterable<Stone>, Sizeable {
return GROUP;
}
// is run
if (stones.get(nonJoker1).getColor() == stones.get(nonJoker2)
.getColor()) {
if (stones.get(nonJoker1).getColor() == stones.get(nonJoker2).getColor()) {
return isValidRun(nonJoker1) ? RUN : INVALID;
}
@ -138,8 +137,7 @@ public class StoneSet implements Iterable<Stone>, Sizeable {
return new Pair<StoneSet, StoneSet>(this, null);
}
StoneSet firstSet = new StoneSet(stones.subList(0, position));
StoneSet secondSet = new StoneSet(stones.subList(position,
stones.size()));
StoneSet secondSet = new StoneSet(stones.subList(position, stones.size()));
return new Pair<StoneSet, StoneSet>(firstSet, secondSet);
}
@ -212,4 +210,19 @@ public class StoneSet implements Iterable<Stone>, Sizeable {
return 1 + 2 * HORIZONTAL_BORDER;
}
@Override
public String toString() {
String ret = "StoneSet[";
boolean first = true;
for (Stone stone : stones) {
if (!first)
ret += ",";
ret += stone.toString();
first = false;
}
return ret + "]";
}
}