git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@471 72836036-5685-4462-b002-a69064685172
106 lines
2 KiB
Java
106 lines
2 KiB
Java
package jrummikub.model;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashSet;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Set;
|
|
|
|
import jrummikub.util.Pair;
|
|
|
|
/**
|
|
* Mock class for {@link Hand}
|
|
*/
|
|
@SuppressWarnings("serial")
|
|
public class MockHand implements IHand {
|
|
/** */
|
|
public List<Pair<Stone, Position>> stones = new ArrayList<Pair<Stone, Position>>();
|
|
/** */
|
|
public Set<Stone> pickups = new HashSet<Stone>();
|
|
/** */
|
|
public Iterable<Pair<Stone, Position>> iterable;
|
|
|
|
@Override
|
|
public void drop(Stone object, Position position) {
|
|
stones.add(new Pair<Stone, Position>(object, position));
|
|
}
|
|
|
|
@Override
|
|
public Position getPosition(Stone object) {
|
|
// TODO Auto-generated method stub
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public boolean pickUp(Stone object) {
|
|
List<Pair<Stone, Position>> itList = new ArrayList<Pair<Stone, Position>>(
|
|
stones);
|
|
for (Pair<Stone, Position> entry : itList) {
|
|
if (entry.getFirst() == object) {
|
|
stones.remove(entry);
|
|
pickups.add(object);
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public int getSize() {
|
|
return stones.size();
|
|
}
|
|
|
|
@Override
|
|
public Iterator<Pair<Stone, Position>> iterator() {
|
|
if (iterable != null) {
|
|
return iterable.iterator();
|
|
} else {
|
|
return stones.iterator();
|
|
}
|
|
}
|
|
|
|
public MockHand clone() {
|
|
try {
|
|
return (MockHand) super.clone();
|
|
} catch (CloneNotSupportedException e) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public int getRowCount() {
|
|
return 0;
|
|
}
|
|
|
|
@Override
|
|
public int getFreeRowSpace(int row) {
|
|
// TODO Auto-generated method stub
|
|
return 0;
|
|
}
|
|
|
|
@Override
|
|
public int getStonePoints(GameSettings settings) {
|
|
// TODO Auto-generated method stub
|
|
return 0;
|
|
}
|
|
|
|
public boolean isInitialMeldPossible(GameSettings settings) {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public int getIdenticalStoneCount() {
|
|
return 0;
|
|
}
|
|
|
|
@Override
|
|
public boolean contains(Stone object) {
|
|
for (Pair<Stone, Position> stone : stones) {
|
|
if (stone.getFirst() == object) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|