summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/model
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 /src/jrummikub/model
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
Diffstat (limited to 'src/jrummikub/model')
-rw-r--r--src/jrummikub/model/IStoneTray.java2
-rw-r--r--src/jrummikub/model/StoneTray.java13
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