diff options
-rw-r--r-- | src/jrummikub/model/StoneTray.java | 7 | ||||
-rw-r--r-- | test/jrummikub/model/StoneTrayTest.java | 13 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/jrummikub/model/StoneTray.java b/src/jrummikub/model/StoneTray.java index 945df13..7f97e1b 100644 --- a/src/jrummikub/model/StoneTray.java +++ b/src/jrummikub/model/StoneTray.java @@ -209,4 +209,11 @@ public class StoneTray<E extends Sizeable> implements }; } + /** + * @param object + */ + public void pickUp(E object) { + objects.remove(object); + } + } diff --git a/test/jrummikub/model/StoneTrayTest.java b/test/jrummikub/model/StoneTrayTest.java index 6c1c170..23d9ea0 100644 --- a/test/jrummikub/model/StoneTrayTest.java +++ b/test/jrummikub/model/StoneTrayTest.java @@ -131,6 +131,7 @@ public class StoneTrayTest { assertEquals(1, thirdPosition.getY(), 0.00001); } + @Test public void testWrongPickUp() { Thing firstThing = new Thing(5, 5); @@ -138,6 +139,18 @@ public class StoneTrayTest { Position testPosition = new Position(-2, -2); assertNull(testTray.pickUp(testPosition)); } + + @Test + public void testPickUpByObject() { + Thing firstThing = new Thing(5,5); + testTray.drop(firstThing, new Position(0, 0)); + Thing secondThing = new Thing(5,5); + testTray.drop(secondThing, new Position(5, 0)); + testTray.pickUp(firstThing); + for (Pair<Thing, Position> i : testTray) { + assertSame(i.getFirst(), secondThing); + } + } @Test public void testRightPickUp() { |