From ea37e2f0d26cdef4537d4792fadcab1dbc4ec337 Mon Sep 17 00:00:00 2001 From: Ida Massow Date: Wed, 4 May 2011 19:39:17 +0200 Subject: Fixed Clone git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@118 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/model/IStoneTray.java | 2 +- src/jrummikub/model/StoneTray.java | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'src/jrummikub/model') 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 extends - Iterable> { + Iterable>, 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 implements IStoneTray { @SuppressWarnings("unchecked") @Override public IStoneTray clone() { - StoneTray copy = new StoneTray(); - copy.objects = (HashMap) objects.clone(); - return copy; + try { + StoneTray copy = (StoneTray) super.clone(); + copy.objects = (HashMap) objects.clone(); + + return copy; + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + + return null; + } } @Override -- cgit v1.2.3