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
Step: 1
Lets implement each of the requested static methods one by one countSuit method This method will cou...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started