Suppose that a class is defined to represent a deck of cards or a player's hand in a card game. This class is implemented as below: A class, also, is defined to develop a card game in which a list of all players' names and their hand is stored.  Part of the implementation of this class looks like the following code:  A) Specify what should be the return type of getPlayersHand()? B) Assume that the cardGame is a composition of Deck. With this assumption, i) implemnt getPlayerHand().  ii) implement the overloaded constructor of Deck. No java methods can be used for part ii.  C) Assume that cardGame is an aggregation of Deck. With this assumption, implement getPalyerHand().  D) An equals() method has been implemented for Deck class. Fill in the gaps to create a fully working equals() method.

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 17RQ
icon
Related questions
Question

Suppose that a class is defined to represent a deck of cards or a player's hand in a card game. This class is implemented as below:

A class, also, is defined to develop a card game in which a list of all players' names and their hand is stored.  Part of the implementation of this class looks like the following code: 

A) Specify what should be the return type of getPlayersHand()?

B) Assume that the cardGame is a composition of Deck. With this assumption, i) implemnt getPlayerHand().  ii) implement the overloaded constructor of Deck. No java methods can be used for part ii. 

C) Assume that cardGame is an aggregation of Deck. With this assumption, implement getPalyerHand(). 

D) An equals() method has been implemented for Deck class. Fill in the gaps to create a fully working equals() method. 

 

Suppose that a class is defined to represent a deck of cards or a player's hand in a card game. This class is implemented as below:
**
* This class defines a Deck of card or
part of the deck that belongs to one
player's hand in a game.
*/
class Deck{
String [] rank;
String [] suit;
public Deck() {
/* rank is initialized by "Ace",
* "2",
*
*
."10", "Jack", "Queen", "King"
*
* suit is initialized by
* "Diamond", "Club", "Heart", "Spade"
*/
}
public Deck(String[] rank, String[] suit) {
// code was removed.
// rank and suit are initialized using the
// input parameters.
}
}
A class, also, is defined to develop a card game in which a list of all players' names and their hand is stored. Part of the implementation of this class looks like the following code:
class CardGame {
String [] players;
ArrayList<Deck> playersHand;
public void shuffle () {
//code was removed.
}
public void deal() {
//code was removed.
}
public
// insert your code here
// you may want to change the return value.
return null;
}
}
getPlayersHand(){
A) Specify what should be the return type of getPlayersHand()?
B) Assume that the cardGame is a composition of Deck. With this assumption, i) implemnt getPlayerHand(). ii) implement the overloaded constructor of Deck. No java methods can be used for part ii.
C) Assume that cardGame is an aggregation of Deck. With this assumption, implement getPalyerHand().
D) An equals() method has been implemented for Deck class. Fill in the gaps to create a fully working equals() method.
@Override
public boolean equals (Object obj) {
if (
return true;
if (
return false;
if (
return - ;
Deck other = (Deck) obj;
return Arrays.equals(rank, other.rank) && Arrays.equals(suit, other.suit);
}
Transcribed Image Text:Suppose that a class is defined to represent a deck of cards or a player's hand in a card game. This class is implemented as below: ** * This class defines a Deck of card or part of the deck that belongs to one player's hand in a game. */ class Deck{ String [] rank; String [] suit; public Deck() { /* rank is initialized by "Ace", * "2", * * ."10", "Jack", "Queen", "King" * * suit is initialized by * "Diamond", "Club", "Heart", "Spade" */ } public Deck(String[] rank, String[] suit) { // code was removed. // rank and suit are initialized using the // input parameters. } } A class, also, is defined to develop a card game in which a list of all players' names and their hand is stored. Part of the implementation of this class looks like the following code: class CardGame { String [] players; ArrayList<Deck> playersHand; public void shuffle () { //code was removed. } public void deal() { //code was removed. } public // insert your code here // you may want to change the return value. return null; } } getPlayersHand(){ A) Specify what should be the return type of getPlayersHand()? B) Assume that the cardGame is a composition of Deck. With this assumption, i) implemnt getPlayerHand(). ii) implement the overloaded constructor of Deck. No java methods can be used for part ii. C) Assume that cardGame is an aggregation of Deck. With this assumption, implement getPalyerHand(). D) An equals() method has been implemented for Deck class. Fill in the gaps to create a fully working equals() method. @Override public boolean equals (Object obj) { if ( return true; if ( return false; if ( return - ; Deck other = (Deck) obj; return Arrays.equals(rank, other.rank) && Arrays.equals(suit, other.suit); }
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Types of Loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,