Work with a deck of cards
Due Date: Wednesday of Week 3
15 points
In this lab, you'll write an application that uses a variety of arrays and for loops to work with a deck of cards.
- Open the CardDeckApp class.
Create an array whole elements hold the first initial of the four different suits (H=Heart, C= Club, S=Spade, D=Diamond. Each suit contains 13 cards) in a card deck. Declare an array that can hold a representation of the cards in a deck of cards without jokers.
Write a method to load the card array, one suit at a time. (Use the numbers 11, 12, and 13 to represent Jacks, Queens, and Kings respectively, and use the number 1 to represent Aces.) Write another method to print the cards in the array, separating each card by a space and printing each suit on a separate line. Call these two methods from the main method. Compile the application and test it to be sure the array is loaded properly.
Write a method that shuffles the deck of cards. To do that, this method should get a number between 1 and 51 by multiplying the result of the random function by 50, converting it to an integer, and adding 1. Then, it should switch each card in the deck with the card that is the given number of cards after it (if there is one). this should be repeated 100 times to shuffle the deck thoroughly. Call this method from the main method, followed by the method that prints the cards array. Test the application to be sure that the cards are shuffled.
Declare a rectangular array that represents four hands of cards with five cards each. Write a method that loads this array by dealing cards from the cards array. Be sure to deal one card at a time to each hand. Write a method that prints the hands, separating the cards in each hand by a space and printing each hand on a separate line. Test the application to be sure that the cards are dealt properly.
Include in your program the following comments:
- Name of program
- Team's name with all the names of the members (e.g. Team A: John Doe, Jane Smith, etc.)
- Current Date
- Computer system and compiler you are using
- Brief description of the program
Compile and run the Java program.
When you are ready, upload the java program by clicking the link below:
Upload Lab
I cannot grade if I don't get the file and receive your email.