summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIda Massow <massow@informatik.uni-luebeck.de>2011-05-04 19:39:17 +0200
committerIda Massow <massow@informatik.uni-luebeck.de>2011-05-04 19:39:17 +0200
commitea37e2f0d26cdef4537d4792fadcab1dbc4ec337 (patch)
treea20ebbb825eda065ee2de65c3fdf6105d4626406
parent3c2950250631abdc82cf48f044ee4ad11ab3c6a1 (diff)
downloadJRummikub-ea37e2f0d26cdef4537d4792fadcab1dbc4ec337.tar
JRummikub-ea37e2f0d26cdef4537d4792fadcab1dbc4ec337.zip
Fixed Clone
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@118 72836036-5685-4462-b002-a69064685172
-rw-r--r--src/jrummikub/model/IStoneTray.java2
-rw-r--r--src/jrummikub/model/StoneTray.java13
-rw-r--r--test/jrummikub/control/RoundControlTest.java2
3 files changed, 13 insertions, 4 deletions
diff --git a/src/jrummikub/model/IStoneTray.java b/src/jrummikub/model/IStoneTray.java
index b40066a..bdf7f86 100644
--- a/src/jrummikub/model/IStoneTray.java
+++ b/src/jrummikub/model/IStoneTray.java
@@ -3,7 +3,7 @@ package jrummikub.model;
import jrummikub.util.Pair;
public interface IStoneTray<E extends Sizeable> extends
- Iterable<Pair<E, Position>> {
+ Iterable<Pair<E, Position>>, Cloneable {
/**
* Removes object from tray and returns it
diff --git a/src/jrummikub/model/StoneTray.java b/src/jrummikub/model/StoneTray.java
index d88d60c..14e9026 100644
--- a/src/jrummikub/model/StoneTray.java
+++ b/src/jrummikub/model/StoneTray.java
@@ -225,9 +225,16 @@ public class StoneTray<E extends Sizeable> implements IStoneTray<E> {
@SuppressWarnings("unchecked")
@Override
public IStoneTray<E> clone() {
- StoneTray<E> copy = new StoneTray<E>();
- copy.objects = (HashMap<E, Position>) objects.clone();
- return copy;
+ try {
+ StoneTray<E> copy = (StoneTray<E>) super.clone();
+ copy.objects = (HashMap<E, Position>) objects.clone();
+
+ return copy;
+ } catch (CloneNotSupportedException e) {
+ e.printStackTrace();
+
+ return null;
+ }
}
@Override
diff --git a/test/jrummikub/control/RoundControlTest.java b/test/jrummikub/control/RoundControlTest.java
index 2e6a7d0..c591563 100644
--- a/test/jrummikub/control/RoundControlTest.java
+++ b/test/jrummikub/control/RoundControlTest.java
@@ -20,5 +20,7 @@ public class RoundControlTest {
assertEquals(14, testGameState.getPlayer(i).getHand().getSize());
}
}
+
+
}