From e4e66240bf864354715f3812f70444d7f7511dd2 Mon Sep 17 00:00:00 2001 From: Ida Massow Date: Tue, 21 Jun 2011 15:23:27 +0200 Subject: =?UTF-8?q?model=20vollst=C3=A4ndig=20dukumentiert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@546 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/model/Hand.java | 18 +++++++++++------- src/jrummikub/model/Table.java | 23 +++++++++++++++++------ 2 files changed, 28 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/jrummikub/model/Hand.java b/src/jrummikub/model/Hand.java index 3e6bfeb..1388187 100644 --- a/src/jrummikub/model/Hand.java +++ b/src/jrummikub/model/Hand.java @@ -47,8 +47,8 @@ public class Hand extends StoneTray implements IHand { } @Override - protected Pair fixInvalidDrop(Stone stone, Position pos, - Direction dir) { + protected Pair fixInvalidDrop(Stone stone, + Position pos, Direction dir) { double x = pos.getX(); double y = pos.getY(); @@ -59,9 +59,11 @@ public class Hand extends StoneTray implements IHand { return new Pair(new Position(0, y), RIGHT); } else { if (getFreeRowSpace((int) y) == 0) { - return new Pair(new Position(0, y + 1), RIGHT); + return new Pair(new Position(0, y + 1), + RIGHT); } else { - return new Pair(new Position(WIDTH - 1, y), LEFT); + return new Pair( + new Position(WIDTH - 1, y), LEFT); } } } @@ -99,8 +101,9 @@ public class Hand extends StoneTray implements IHand { * Increments the count of a stone in the list of all stones * * @param stones - * all stones and their respective numbers + * all stones and their respective numbers * @param stone + * the start stone */ private static void incrementStoneCount( TreeMap, Integer> stones, @@ -132,7 +135,7 @@ public class Hand extends StoneTray implements IHand { * Counts the numbers of stones * * @param stones - * the stones to count + * the stones to count * @return the numbers for all stones */ private static Pair, Integer>, Integer> countStones( @@ -159,7 +162,8 @@ public class Hand extends StoneTray implements IHand { public int getIdenticalStoneCount() { List stones = new ArrayList(); - for (Iterator> iter = this.iterator(); iter.hasNext();) { + for (Iterator> iter = this.iterator(); iter + .hasNext();) { stones.add(iter.next().getFirst()); } diff --git a/src/jrummikub/model/Table.java b/src/jrummikub/model/Table.java index 1b355db..3fb9b5c 100644 --- a/src/jrummikub/model/Table.java +++ b/src/jrummikub/model/Table.java @@ -25,7 +25,7 @@ public class Table extends StoneTray implements ITable { * Constructor for a table * * @param settings - * GameSettings + * GameSettings */ public Table(GameSettings settings) { gameSettings = settings; @@ -35,7 +35,7 @@ public class Table extends StoneTray implements ITable { * Removes {@link Stone} from the Table * * @param stone - * stone to pick up + * stone to pick up */ @Override public void pickUpStone(Stone stone) { @@ -50,7 +50,7 @@ public class Table extends StoneTray implements ITable { * Finds {@link StoneInfo} * * @param stone - * the stone + * the stone * @return the info */ private StoneInfo findStoneInfo(Stone stone) { @@ -89,11 +89,22 @@ public class Table extends StoneTray implements ITable { return info.set; } + /** + * Splits a stone set at a specified position + * + * @param set + * the stone set to split + * @param setPosition + * the set's position on the table + * @param stonePosition + * the stone after which splitting should occur + */ private void splitSet(StoneSet set, Position setPosition, int stonePosition) { pickUp(set); Pair firstSplit = set.splitAt(stonePosition); - Pair secondSplit = firstSplit.getSecond().splitAt(1); + Pair secondSplit = firstSplit.getSecond() + .splitAt(1); StoneSet leftSet = firstSplit.getFirst(); StoneSet rightSet = secondSplit.getSecond(); @@ -101,8 +112,8 @@ public class Table extends StoneTray implements ITable { if (set.classify(gameSettings).getFirst() == StoneSet.Type.RUN) { Position leftPosition, rightPosition; leftPosition = setPosition; - rightPosition = new Position(setPosition.getX() + stonePosition + 1, - setPosition.getY()); + rightPosition = new Position( + setPosition.getX() + stonePosition + 1, setPosition.getY()); drop(leftSet, leftPosition); drop(rightSet, rightPosition); -- cgit v1.2.3