Fixed Clone

git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@118 72836036-5685-4462-b002-a69064685172
This commit is contained in:
Ida Massow 2011-05-04 19:39:17 +02:00
parent 3c29502506
commit ea37e2f0d2
3 changed files with 13 additions and 4 deletions

View file

@ -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

View file

@ -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

View file

@ -20,5 +20,7 @@ public class RoundControlTest {
assertEquals(14, testGameState.getPlayer(i).getHand().getSize());
}
}
}