Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Technically, rank may also be called pips. A pip is a mark on a card. Traditiona

ID: 3757187 • Letter: T

Question

Technically, rank may also be called pips. A pip is a mark on a card. Traditionally, cards will have the rank
expressed as a string (e.g. 2, 3,. . . , 10, J, Q, K, or A) along with a number of pips equal to the value of
the card (2, 3,. . . , 10). However, face cards do not have pips so the corresponding pip count would be zero.

A deck of cards is an ordered set of cards. A standard deck is built from the cards {2, 3. . . , 10, jack,
queen, king, ace} from each suit (clubs, diamonds, hearts, and spades), which means a standard deck has
52 cards. However, there are other types of decks as well:
1. A Euchre deck, which is composed of 9, 10, J, Q, K, and A of the four suits 24 cards in total.
2. A pinochle deck, which is composed 9, 10, J, Q, K, and A of the four suits, but there are two copies
of each suit. There are 48 cards in total.
3. A Vegas blackjack deck. It's composed of two or more standard decks. Typically it's six to eight
decks.

The following JUnit test should be included in test suite. All tests
must pass. At a minimum, you must test:
1. The creation of individual cards (meaning test that a card has the right suit and rank)
2. A deck has the right cards in it and the right number of cards.
3. A deck after being shuffled has a different order than before.
4. A deck after being sorted by rank, suit, or both rank and suit, is in the expected order.
5. A deck after being cut is in the right order.
6. A deck after a card is pulled has one less card than before that card was pulled (and that card is
no longer in the deck). Beware of the pinochle deck for this test case!
7. An empty deck is indeed empty. A deck with cards in it is indeed not empty.
8. A hand is properly constructed.
9. A hand properly accepts a card.
10. When a card is pulled from the hand, the hand now has one less card and that card is no longer in
the deck. Op cit, beware the pinochle deck. . .
11. The hand tells accurately whether a particular card, rank, or suit is present.
12. The hand properly sorts the card by suit, rank, or both suit and rank.
13. The hand properly shuffes the cards in it.
14. A similar list pertains to the game as well.

Want to create a version where all games are created so that it is easy to create specialized types
of games (decks or hands) and to perform additional operations when either is being created. Solu-
tion should make it easy to vary between different specialized creation options. For example, you should
be able to build a five-card hand from a euchre deck, a pinochle deck, or a standard deck easily and directly.

Can someone help me with this homework with a solution as I am new to Java and JUnit and finding it difficult to implement this.

eeinterface Deck Hand > Card Game + void shuffieO + void sort String bySuit-Rank-both) + void cuto +Card puliCardO: +List-Card showCards0; +void accept(Card) +Card pullCard0, +void createDeck String deckType), + void createDeck (String deckType, +Rank getRank); +Suit getSuito int numberOfDecks) Boolean hasCard(Card) +void sor String bySuit-Rank-both) +void setNumberOlHands(int) Boolean emptyDeckO, void dealo eeinterface> Rank String getName0 +int getPips einterface> Standard Pinochle Euchre Vegas Suit shuffle0 +Boolean sort) +Boolean shuffle) shuffle0 +String getName0 +char getSymbolO: shuffle0 +Boolean sort0 +Boolean shuffie +Boolean sort0 Boolean shuffie0 +Boolean cuto + Boolean sort) Boolean shuffle Boolean cuto Boolean cuto Boolean cut)

Explanation / Answer

1) Card.java


package interfaceexamples;


public interface Card {
Rank getRank();
Suit getSuit();
}

2) Deck.java


package interfaceexamples;


public interface Deck {
void shuffle();
void sort(String bySuit_Rank_Both);
void cut();
Card pullCard();
Boolean emptyDeck();
}

3) Euchre.java


package interfaceexamples;


public abstract class Euchre implements Deck{

@Override
public void shuffle() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}

@Override
public void sort(String bySuit_Rank_Both) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}

@Override
public void cut() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
  
}

4) Game.java


package interfaceexamples;

public interface Game {
void createDeck(String deckType);
void createDeck(String deckType, int numberOfDecks);
void setNumberOfHands(int no);
void deal();
  
}

5) Hand.java


package interfaceexamples;
import java.util.List;

public interface Hand {
List<Card> showCards();
void accept(Card c);
Card pullCard();
Boolean hasCard(Card c);
void sort(String bySuit_Rank_both);
}

6) Pinochle.java


package interfaceexamples;


public abstract class Pinochle implements Deck{

@Override
public void shuffle() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}

@Override
public void sort(String bySuit_Rank_Both) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}

@Override
public void cut() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
  
}

7) Rank.java


package interfaceexamples;

public interface Rank {
String getName();
int getPips();
}

8) Standard.java


package interfaceexamples;

public abstract class Standard implements Deck{
// override all methods that are needed .

@Override
public abstract void cut();

@Override
public abstract void sort(String bySuit_Rank_Both);

@Override
public abstract void shuffle();
  
}

9) Suit.java


package interfaceexamples;

public interface Suit {
String getName();
char getSymbol();
}

10)Vegas.java


package interfaceexamples;

public abstract class Vegas implements Deck{

@Override
public void shuffle() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}

@Override
public void sort(String bySuit_Rank_Both) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}

@Override
public void cut() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
  
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote