Help me code this in C# (Need it ASAP). Help me with the second one (Array List). Here is my PlayingCard class just in case, but u can rewrite this class from the first picture.
public class PlayingCard
{
PortableMusicPlayer p1 = new PortableMusicPlayer();
PortableMusicPlayer p2 = new PortableMusicPlayer();
public string[] suite = { "Clubs", "Diamonds", "Hearts", "Spades" };
public string[] value = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" };
public string suite1;
public string value1;
public PlayingCard(int v, int s)
{
Console.WriteLine(value[v] + " of " + suite[s]);
}
public PlayingCard(string v, string s)
{
value1 = v;
suite1 = s;
}
public override string ToString()
{
return value1 + " of " + suite1;
}
}
Extracted text: Begin with the following code, and the class you defined in #1 (you can assume it works even if you couldn't code #1): Java C# import java.util.ArrayList; using System; import java.util.Random; using System.Collections. Generic; class Main { class Mainclass { public static void main(String[] args) { public static void Main (string[] args) { Random myrand = new Random( ); Random myrand new Random(); %3D String[] suites = string[] suites = {"Clubs","Diamonds","Hearts","Spades"}; {"Clubs","Diamonds","Hearts","Spades"}; String[] values string[] values = {"A","2","3","4","5","6","7","8","9","10","J", {"A","2","3","4","5","6","7","8","9","10","J", "Q", "K"}; "Q", "K"}; //Insert code here //Insert code here } } } } Add code to do the following things: 1) Create an ArrayList (java) or List (C#) called Deck of PlayingCard (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 PlayingCard 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 PlayingCard objects to the ArrayList. e) Hint: You should use a nested loop to do this step 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); 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 Java: 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 question.
Extracted text: Using repl.it, write a class called PlayingCard. A playing card has a suite (string) which will be either Clubs, Diamonds, Hearts or Spades. And a value (string) which will be either A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q or K. Add a constructor which takes in a suite and value and sets them in the object. Override toString (Java) or ToString (C#) so it returns [value] of [suite]. For example: “A of Hearts" or "3 of Spades". Paste (ctrl v) all your code from repl.it into this box: