Please write in java. I have a code but it isn't working correctly. Thanks in advance.
A playing card is a piece of specially prepared paper that is marked with distinguishing motifs. The 52-card deck is the most popular deck and includes 13 ranks of 4 suits. The ranks are Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King. The suits are composed of clubs ( ), diamonds (*), hearts ( ) and spades (). An example of a 52 card deck is shown in Figure 3: Typical 52 Card Deck Suits and Ranks. For this problem, we will model a 52 card deck using three classes: clsCard to represent an individual card, clsCard Deck to represent a 52 card deck, and clsGame to manipulate a clsCard Deck. 3 do 4 de Figure 3: Typical 52 Card Deck Suits and Ranks 1. Create a Java file called clsCard.java. Do not add a main() method to clsCard.java 2. At the top of your .java file add the following documentation comments // Your Name // CS110 Section XX // Assignment XX // Todays Date 3. Create two instance variables of type String named strsuit and strvalue. 4. Create a constructor of clsCard with two parameters of type String named suit and value. a. In the body of the constructor, use the this reference to assign the instance variables to the corresponding parameter values. b. Add a JavaDoc comment before the constructor signature with an explanation of your choice. The JavaDoc must be a complete sentence and explain what the method does. The parameters must be explained. 5. Create a method with the signature public String getSuit(). This method does not take any parameters and returns the suit as a String. a. In the body of the method, return the instance variable strsuit. b. Add a JavaDoc comment before the method signature with an explanation of your choice. The JavaDoc must be a complete sentence and explain what the method does. The return value must be explained. 6. Create a method with the signature public String getValue(). This method does not take any parameters and returns the value as a String. a. In the body of the method, return the instance variable strvalue. b. Add a JavaDoc comment before the method signature with an explanation of your choice. The JavaDoc must be a complete sentence and explain what the method does. The return value must be explained. 7. Create a method with the signature public String toString(). This method does not take any parameters and returns a String formatted as "
of ". a. In the body of the method, return a String consisting of the strvalue, concatenated with the string literal" of " concatenated with the strsuit. b. Add a JavaDoc comment before the method signature with an explanation of your choice. The JavaDoc must be a complete sentence and explain what the method does. The return value must be explained. 8. Create a Java file called clsCardbeck.java in the same project directory as clscard.java. Do not add a main() method to clscardbeck.java. 9. Import the java.util.ArrayList library. 10. At the top of your .java file, below the import statement, add the following documentation comments // Your Name // CS110 Section xx // Assignment XX // Todays Date 11. Create a constant String array named SUITS. Initialize the array with the values "Clubs", "Diamonds", "Hearts", "Spades". 12. Create an instance variable of an ArrayList of type clsCard named deck. 13. Create a constructor of the clsCard Deck with no parameters. a. In the body of the constructor, do the following: i. Use a nested loop structure to iterate over the suits and values. In the outer loop iterate over the integer values 0 to 3 inclusive. We will use these values as the positions in the SUITS array when we are instantiating the cards. HINT: THE VALUES O TO 3 WILL BE USED TO INDEX THE SUITS ARRAY. 1. In the inner loop, iterate over the values 1 to 13 inclusive. We will use the iteration number as the value of the card. However, iteration 1 value is "ace" and iterations 11, 12, and 13 are jack, queen, king respectively. a. In the body of the inner loop, we will use a nested decision structure to create a new clsCard object of the SUIT and value. HINT: EACH TIME YOU CREATE A CLSCARD, YOU NEED TO USE THE NEW KEYWORD. The decision structure should implement the following conditions: b. If the inner loop iteration is 1, the value should be "Ace". Create a new object of type clsCard with SUIT indexed by the value of the outer loop iteration and value "Ace". C. If the inner loop iteration is 2 to 10 inclusive, the value should be a string representation of the iteration number. Create a new object of type clsCard with SUIT indexed by the value of the outer loop iteration and use the .toString() method of the Integer class to convert the iteration number to a String representing the value. d. If the inner loop iteration is 11, the value should be "Jack". Create a new object of type clsCard with SUIT indexed by the value of the outer loop iteration and value "Jack". e. If the inner loop iteration is 12, the value should be "Queen". Create a new object of type clsCard with SUIT indexed by the value of the outer loop iteration and value "Queen". f. If the inner loop iteration is 13, the value should be "King". Create a new object of type clsCard with SUIT indexed by the value of the outer loop iteration and value "King". b. Add a JavaDoc comment before the constructor signature with an explanation of your choice. The JavaDoc must be a complete sentence and explain what the method does. 14. Create a method with the signature public void shuffle(). The method does not take any parameters and does not return anything. The purpose of this method is the simulate a shuffle of a 52 card deck. a. In the body of the method use a loop to iterate over the values from 0 to the size of the deck. b. In the body of the loop, do the following: i. Create a local variable of type int named intrandomPosition. Assign the integer casting of the product of a pseudo random number using the .random() method of the Math class multiplied by the size of the deck using the .size() method. ii. Create a local variable of type clsCard named card and assign the result of calling the .remove() method with the parameter intrandomPosition on the object deck to card. iii. Overwrite the value in intrandomPosition by assigning the integer casting of the product of a pseudo random number using the .random() method of the Math class multiplied by the size of the deck using the .size() method. HINT: WE HAVE TO OVERWRITE INTRANDOMPOSITION TO CREATE A NEW PSEUDO RANDOM NUMBER. iv. Use the .add() method on the object deck with the parameters intrandomposition and card. HINT: WE ARE ADDING THE CARD BACK TO THE DECK IN A RANDOM POSITION. c. Add a JavaDoc comment before the method signature with an explanation of your choice. The JavaDoc must be a complete sentence and explain what the method does. 15. Create a method with the signature public int deckSize(). The method does not take any parameters and returns a value of type int representing the number of cards in the deck object. a. In the body of the method return the size of the deck object using the .size() method. b. Add a JavaDoc comment before the method signature with an explanation of your choice. The JavaDoc must be a complete sentence and explain what the method does. The return value must be explained. 16. Create a method with the signature public String viewCard(int position InDeck). The method takes one parameter of type int named position InDeck and returns the String representation of a clsCard's value and suit using the clsCard's .toString() method. a. In the body of the method return the String representation of the clsCard object in the deck object using a nested function call composed of the .get() method of the deck object with parameter position InDeck and the .toString() method of the clsCard class. b. Add a JavaDoc comment before the method signature with an explanation of your choice. The JavaDoc must be a complete sentence and explain what the method does. The parameter and return value must be explained. 17. Create a Java file called clsGame.java in the same project directory as clscard.java and clscardDeck.java. Add a main() method to clsGame.java. 18. Create a method after the main method with the signature public static void printDeck(clsCard Deck deck). The method takes 1 parameter of type clsCard Deck and does not return anything. The purpose of this method is to print the suit and value of each card in the deck. a. In the body of the method, use a loop to iterate over each position in deck and print the card's value and suit using the the .viewCard() method on the deck object to the console. 19. In the main method, do the following: a. Create a new object of type clsCardDeck named deck. b. Print the string literal "Before shuffling: " to the console. c. Use the printDeck() method with deck as the argument. d. Print the string literal "After shuffling: "to the console. e. Use the .shuffle() method on the deck object. f. Use the printDeck() method with deck as the argument. The result of the deck after instantiation and after shuffling are shown in Figure 4: Example Output Before Shuffling Deck and Figure 5: Example Output After Shuffling Deck respectively. @ Console X Problems Debug Shell clsGame [Java Application] C:\Program Files U Before shuffling: Ace of Clubs 2 of Clubs 3 of clubs 4 of Clubs 5 of clubs 6 of clubs 7 of clubs 8 of Clubs 9 of clubs 10 of Clubs Jack of Clubs Queen of Clubs King of Clubs Ace of Diamonds 2 of Diamonds Figure 4: Example Output Before Shuffling Deck Console X i Problems Debug Shell clsGame [Java Application] C:\Program Files After shuffling: 10 of Diamonds 4 of Hearts 7 of Spades Jack of Clubs 4 of Clubs 6 of Diamonds 5 of Clubs 6 of Clubs 3 of Clubs 9 of Clubs 10 of Clubs Ace of Diamonds 10 of Hearts King of Diamonds 2 of Diamonds Figure 5: Example Output After Shuffling Deck