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(); 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.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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;
    }
}

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.
Transcribed Image 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.
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:
Transcribed Image 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:
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY