diff options
Diffstat (limited to 'src/jrummikub/model')
-rw-r--r-- | src/jrummikub/model/IStoneTray.java | 2 | ||||
-rw-r--r-- | src/jrummikub/model/StoneTray.java | 13 |
2 files changed, 11 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 |