Tests for counting of identical stone pairs
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@274 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
a1c0cb89f6
commit
5e855398b9
4 changed files with 41 additions and 2 deletions
|
@ -86,4 +86,9 @@ public class MockHand implements IHand {
|
||||||
public boolean isInitialMeldPossible() {
|
public boolean isInitialMeldPossible() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getIdenticalStoneCount() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,4 +261,10 @@ public class Hand extends StoneTray<Stone> implements IHand {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getIdenticalStoneCount() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,5 +34,12 @@ public interface IHand extends IStoneTray<Stone> {
|
||||||
*
|
*
|
||||||
* @return true if an initial meld is possible
|
* @return true if an initial meld is possible
|
||||||
*/
|
*/
|
||||||
public abstract boolean isInitialMeldPossible();
|
public boolean isInitialMeldPossible();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Counts the pairs of identical stones
|
||||||
|
*
|
||||||
|
* @return number of identical stone pairs
|
||||||
|
*/
|
||||||
|
public int getIdenticalStoneCount();
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,11 +132,15 @@ public class HandTest {
|
||||||
assertEquals(56, hand.getStonePoints());
|
assertEquals(56, hand.getStonePoints());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testInitialMeld(boolean possible, List<Stone> handStones) {
|
private void dropStoneList(List<Stone> handStones) {
|
||||||
hand = new Hand(new GameSettings());
|
hand = new Hand(new GameSettings());
|
||||||
for (Stone stone : handStones) {
|
for (Stone stone : handStones) {
|
||||||
hand.drop(stone, new Position(0, 0));
|
hand.drop(stone, new Position(0, 0));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testInitialMeld(boolean possible, List<Stone> handStones) {
|
||||||
|
dropStoneList(handStones);
|
||||||
assertTrue(possible == hand.isInitialMeldPossible());
|
assertTrue(possible == hand.isInitialMeldPossible());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,4 +244,21 @@ public class HandTest {
|
||||||
new Stone(11, BLUE), new Stone(RED)));
|
new Stone(11, BLUE), new Stone(RED)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** */
|
||||||
|
@Test
|
||||||
|
public void testCountIdenticalStones() {
|
||||||
|
dropStoneList(Arrays.asList(new Stone(1, RED), new Stone(2, RED), new Stone(1, BLUE)));
|
||||||
|
assertEquals(0, hand.getIdenticalStoneCount());
|
||||||
|
dropStoneList(Arrays.asList(new Stone(1, RED), new Stone(1, RED), new Stone(1, BLUE)));
|
||||||
|
assertEquals(1, hand.getIdenticalStoneCount());
|
||||||
|
dropStoneList(Arrays.asList(new Stone(1, RED), new Stone(1, RED), new Stone(1, BLUE), new Stone(1, BLUE)));
|
||||||
|
assertEquals(2, hand.getIdenticalStoneCount());
|
||||||
|
dropStoneList(Arrays.asList(new Stone(1, RED), new Stone(1, RED), new Stone(1, RED)));
|
||||||
|
assertEquals(1, hand.getIdenticalStoneCount());
|
||||||
|
dropStoneList(Arrays.asList(new Stone(1, RED), new Stone(1, RED), new Stone(1, RED), new Stone(1, RED)));
|
||||||
|
assertEquals(2, hand.getIdenticalStoneCount());
|
||||||
|
dropStoneList(Arrays.asList(new Stone(RED), new Stone(RED)));
|
||||||
|
assertEquals(0, hand.getIdenticalStoneCount());
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue