From b86571cf832ff13010798f3607eea6ad0ef039d0 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 9 May 2011 00:33:34 +0200 Subject: Allow laying out stone sets git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@180 72836036-5685-4462-b002-a69064685172 --- mock/jrummikub/model/MockHand.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'mock/jrummikub/model/MockHand.java') diff --git a/mock/jrummikub/model/MockHand.java b/mock/jrummikub/model/MockHand.java index dc4dd04..994f7f5 100644 --- a/mock/jrummikub/model/MockHand.java +++ b/mock/jrummikub/model/MockHand.java @@ -8,7 +8,7 @@ import jrummikub.util.Pair; public class MockHand implements IHand { - public List stones = new ArrayList(); + public List> stones = new ArrayList>(); public Iterable> iterable; @@ -19,7 +19,7 @@ public class MockHand implements IHand { @Override public void drop(Stone object, Position position) { - stones.add(object); + stones.add(new Pair(object, position)); } @Override @@ -30,7 +30,12 @@ public class MockHand implements IHand { @Override public void pickUp(Stone object) { - stones.remove(object); + List> itList = new ArrayList(stones); + for (Pair entry : itList) { + if (entry.getFirst() == object) { + stones.remove(entry); + } + } } @Override @@ -40,7 +45,11 @@ public class MockHand implements IHand { @Override public Iterator> iterator() { - return iterable.iterator(); + if (iterable != null) { + return iterable.iterator(); + } else { + return stones.iterator(); + } } public MockHand clone() { -- cgit v1.2.3