Question: Writ a static method `countSuit` that takes a hand (as an ArrayList) of cards as well as a suit name (as a string) as input,

Writ a static method `countSuit` that takes a hand (as an ArrayList) of cards as well as a suit name (as a string) as input, and that returns the number of cards in the hand that have the named suit.

 

Writ a static method `isFlush` that takes a hand (as an ArrayList) of cards as input, and that returns `true` if all the cards in the hand are the same suit. Otherwise, it should return `false`.
   
Writ a static method `hasPair` that takes a hand (as an ArrayList) of cards as input, and that returns `true` if there is any pair of cards in the hand that have the same rank.
   
Writ a static method `swapAdjacent` that takes an ArrayList of an EVEN number of integers as input, and that updates this list by swapping the locations of each pair of adjacent elements. e.g. if `list` has string representation [3, 7, 12, 9, 4, 8],then `swapAdjacent(list)` should update `list` to have string representation [7, 3, 9, 12, 8, 4].

 

Writ a static method `removeRepetition` that takes an ArrayList of integers as input, and that returns a new ArrayList that contains the same elements as the input, except all ADJACENT repetition has been removed e.g. if `list` has string representation [3, 4, 4, 6, 4, 3, 3, 3, 1, 1],Then `removeRepetition(list)` should return the new list with string representation [3, 4, 6, 4, 3, 1].

Step by Step Solution

3.44 Rating (157 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Lets implement each of the requested static methods one by one countSuit method This method will cou... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!