Question: java please. Add 1-3 to existing code Ic Java 3 u import java.util.ArrayList; import java.util.Random; 6 class Main public static void main(String[] args) { Random
![java.util.ArrayList; import java.util.Random; 6 class Main public static void main(String[] args) {](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f642616e987_88066f64260f3eae.jpg)
![Random myrand = new Random(); String[] suites = {"Clubs","Diamonds", "Hearts","Spades"); String() values](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f642620cca7_88166f64261a3e39.jpg)
Ic Java 3 u import java.util.ArrayList; import java.util.Random; 6 class Main public static void main(String[] args) { Random myrand = new Random(); String[] suites = {"Clubs","Diamonds", "Hearts","Spades"); String() values = ("A"2":"3":"4","5","6","7","8","9":"10","J", "Q":"K"}= // Insert code here } 1. Create an ArrayList (java) or List (C#) called Deck of Playing Card (the Class you defined in the previous question). a. You will put an object of type PlayingCard into each cell of the ArrayList/List. b. The first Playing Card should be an "A of Clubs", ie, it's value should be A. it's suite should be Clubs. Next add a "2 of Clubs", "3 of Clubs", "4 of Clubs" ... "Q of Clubs"... "K of Clubs". c. Repeat step b above for Diamonds, Hearts and Spades. d. Thus you'll add all 13 values (A, 2, 3, 4, 5, 6, 7, 8, 9, 10,J,Q,K) of each of the 4 suites, so you should end up adding 52 Playing Card objects to the ArrayList. e. Hint: You should use a nested loop to do this step Next, you will create a "hand" of 5 unique cards in a new ArrayList/List. a. You'll do this by picking a random number between 0 and 51 using: C#: int pos=myrand.Next(51); Java: int pos=myrand.nextInt(51); 2. Next, you will create a "hand" of 5 unique cards in a new ArrayList/List. a. You'll do this by picking a random number between 0 and 51 using: C#: int pos-myrand.Next(51): Java: int pos-myrand.nextInt(51); b. If you've not picked that number before, you'll add the card that is in the Deck ArrayList/List at that position you just randomly picked to the Hand ArrayList/List c. You'll have to keep track of which numbers you've picked so you don't accidentally add the same card twice. 3. Finally, print out the 5 cards of the hand ArrayList/List. You must use the toString (Java) or ToString (C#) override you put in the class in the last
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
