So basically I'm trying to test to see if my hand of 5 cards has a pair in it (two cards have the same value (1-9)) and I'm getting an unknown error and this is my code
Error:
java.lang.AssertionError at org.junit.Assert.fail(Assert.java:86)...
Code:
public static boolean hasPair(Card[] cards) {
Deck theDeck = new Deck();
cards = theDeck.deal(5);
int k=0;
for (int atPos = 0; atPos<5; atPos++){
for (int atPos2 = atPos+1; atPos2<5; atPos2++){
if(cards[atPos].getValue() == cards[atPos2].getValue()){
k++;
}
}
}
if (k==2){
return true;
}
else {
return false;
}
JUnit that is failing
@Test
public void testExampleTest_SinglePairTest() {
Card[] testHand = new Card[5];
testHand[0] = new Card(1,1);
testHand[1] = new Card(2,1);
testHand[2] = new Card(2,1);
testHand[3] = new Card(4,1);
testHand[4] = new Card(5,1);
assertTrue(HandEvaluatorBBXP.hasPair(testHand));