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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education