Question: test case: public void testHandSequenceLength ( ) { deck = new Deck ( ) ; hand 1 = new Hand ( Amina ,
test case:
public void testHandSequenceLength
deck new Deck;
hand new HandAmina deck;
assertEquals handsequenceLength;
deck new Deck;
hand new HandNina deck;
assertEquals handsequenceLength;
ArrayList cards new ArrayList;
cards.addnew Cardnew RankTwo new SuitHeartsH "red", ;
cards.addnew Cardnew RankFour new SuitHeartsH "red", ;
cards.addnew Cardnew RankKingK new SuitHeartsH "red", ;
cards.addnew Cardnew RankEight new SuitHeartsH "red", ;
cards.addnew Cardnew RankThree new SuitClubsC "black", ;
cards.addnew Cardnew RankQueenQ new SuitHeartsH "red", ;
hand new HandAmina cards;
assertEquals handsequenceLength;
cards.addnew Cardnew RankAceA new SuitClubsC "Black", ;
hand new HandAmina cards;
assertEquals handsequenceLength;
cards.addnew Cardnew RankJackJ new SuitHeartsH "red", ;
cards.addnew Cardnew RankTenX new SuitClubsC "black", ;
cards.addnew Cardnew RankNine new SuitHeartsH "red", ;
hand new HandAmina cards;
assertEquals handsequenceLength;
currentMethodName new ObjectgetClassgetEnclosingMethodgetName;
my code isn't passing the test cases. the question says to return the length of the longest "sequence: of cards in the hand.
public int sequenceLength
if cardsInHandisEmpty
return ;
arrange;
ArrayList ranks new ArrayList;
for Card card : cardsInHand
ranks.addcardrank.value;
if cardrank.value
ranks.add;
ranks.sortnull;
int maxLength ;
int currentLength ;
for int i ; i ranks.size; i
if ranksgeti ranks.geti
currentLength;
else if ranksgeti ranks.geti
maxLength Math.maxmaxLength currentLength;
currentLength ;
maxLength Math.maxmaxLength currentLength;
return maxLength;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
