Question: project ch12_ex1_CardDeck includes the following class CardDeckApp.java import java.util.Arrays; public class CardDeckApp { public static void main(String[] args) { System.out.println(DECK); String[] deck = getDeck(); displayCards(deck);

 project ch12_ex1_CardDeck includes the following class CardDeckApp.java import java.util.Arrays; public classCardDeckApp { public static void main(String[] args) { System.out.println("DECK"); String[] deck =getDeck(); displayCards(deck); System.out.println("SHUFFLED DECK"); shuffleDeck(deck); displayCards(deck); int count = 2; System.out.println("HAND OF

project ch12_ex1_CardDeck includes the following class

CardDeckApp.java

import java.util.Arrays;

public class CardDeckApp {

public static void main(String[] args) { System.out.println("DECK"); String[] deck = getDeck(); displayCards(deck);

System.out.println("SHUFFLED DECK"); shuffleDeck(deck); displayCards(deck);

int count = 2; System.out.println("HAND OF " + count + " CARDS"); String[] hand = dealCards(deck, count); displayCards(hand); }

private static String[] getDeck() { String[] suits = {"Spades", "Hearts", "Diamonds", "Clubs"}; String[] ranks = {"Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"};

String[] deck = new String[52]; int i = 0; for (String suit : suits) { for (String rank : ranks) { deck[i] = rank + " of " + suit; i++; } } return deck; }

private static void displayCards(String[] cards) { System.out.print("|"); for (String card : cards) { System.out.print(card + "|"); } System.out.println(); }

private static void shuffleDeck(String[] deck) { for (int i = 0; i

private static String[] dealCards(String[] deck, int count) { String[] hand = Arrays.copyOfRange(deck, 0, count); return hand; } }

1. Use proper statement indentation and meaningful variable names in the code.

2. Add a multi-line description of this application that also includes your name and the date written at the beginning of the code.

3. Add appropriate descriptive comments to each line of code you add to the project explaining why the code is in the application.

WIn Collections and generics 415 Exercise 12-1 Use an array list rhis exercise has you modify the Card Deck application of exercise 11-4 soit ses array lists instead of arrays for the deck of cards and the hands. DECK lAce of Spades 2 of Spades 3 of Spades 4 of Spades .. SHUFFLED DECK ixing of teart al king of Hearts|Jack of Clubs |King of Diamonds | 9 of Hearts... FOUR HANDS OF 2 CARDS King of Hearts King of Diamonds Jack of clubs|3 of Spades| 9 of Hearts 5 of Hearts| 8 of Clubs | Jack of Hearts] CARDS LEFT IN DECK: 44 Open the project and add the required import statement 1. Open the project named ch12_ex1_CardDeck in the ex _starts directory. Then, review the code for this application and run it to refresh your memory on how it works. Add an import statement to the CardDeckApp file that makes the ArrayList class available. 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!