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 ++++++++++--- test/jrummikub/control/RoundControlTest.java | 2 ++ 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 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 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()); } } + + } -- cgit v1.2.3