Question: Hello. I would like help with question number 7 please. 7. Modify the dealCards() method so it accepts and returns an array list instead of
Hello. I would like help with question number 7 please. 7. Modify the dealCards() method so it accepts and returns an array list instead of an array. Then, modify the statement in the main() method that calls the dealCards() method so it stores the hand in an array list instead of an array.






As you can see from the photos, I tried solving it myself with no luck.
How to work with collections and generics Exercise 12-1 This exercise has you modify the Card Deck application of exercise 11-4 so it uses array lists instead of arrays for the deck of cards and the hands. Ace of Spades | 2 of Spades 3 of Spades | 4 of Spades ... King of Hearts Jack of Clubs King of Diamonds | 9 of Hearts ... Chapter 12 Use an array list FOUR HANDS OF 2 CARDS King of Hearts King of Diamonds Jack of clubs | 3 of Spades 19 of Hearts 5 of Heartel 8 of clubs Jack of Hearts CARDS LEFT IN DECK: 44 DECK SHUFFLED DECK 4. Open the project and add the required import statement 1. Open the project named ch12_exl_CardDeck in the ex_starts directory. Then, review the code for this application and run it to refresh your memory on how it works. 2. Add an import statement to the Card DeckApp file that makes the ArrayList class available. Modify the application to use array lists 3. Modify the declaration for the getDeck() method so it returns an array list of strings instead of an array of strings. Then, modify the code in this method so it stores the cards in an array list instead of an array. When you declare the array list, set its capacity to 52 since that's the maximum number of cards. Modify the statement in the main() method that calls the getDeck() method so it stores the deck in an array list instead of an array. 5. Modify the displayCards() method so it accepts an array list instead of an array. Since the code for this method uses an enhanced for loop, no additional changes are needed. 6. Modify the shuffle Deck() method so it accepts an array list instead of an array. Then, modify the code for this method so it uses the array list. 7. Modify the dealCards() method so it accepts and returns an array list instead of an array. Then, modify the code for this method so it gets and removes the specified number of cards from the deck and adds them to the hand. 8. Delete the import statement for the Arrays class since it's no longer needed. Then, modify the statement in the main() method that calls the dealCards() method so it stores the hand in an array list instead of an array. Test the application to be sure it works like it did before. ols Window Help 2614584 CMD ardDeckApp.java X History System.out.print(""); cards.forEach (card -> { System.out.print(card + "I); }); System.out.println(); } private static void shuffleDeck (ArrayList
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
