summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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());
}
}
+
+
}