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

2: Deck of Cards Complete the provided Deck class. The class has two constructor

ID: 3919145 • Letter: 2

Question

2: Deck of Cards
Complete the provided Deck class. The class has two constructors:


public Deck()
// purpose: creates a deck of 52 standard cards
// (one card for each rank/suit combination; no Jokers)


public Deck(int num_jokers)
// purpose: creates a deck of (52 + num_jokers) cards
// consisting of the 52 standard cards
// plus num_joker Joker cards


You will also complete the following public methods:


public List getCards(int num_cards){return null;}
// purpose: remove and return num_cards cards from this deck
// removes the first num_cards from the deck


public Card getCard(){return null;}
// purpose: remove and return a single card from this deck
// removes the first card from the deck


public void addCard(Card c){}
// purpose: adds the card c to the back of the deck


Your must use encapsulation for this class. You can add any private/protected attributes and helper
methods that you need. You should not have any static attributes or methods (except possibly a
main method that you use for testing the class).


Note: You can use any concrete List that Java’s Collection Framework (JCF) provides.

EDIT: my apologies, here is the card class:

Explanation / Answer

I am giving you deck class implementation, which uses Card class constructor.. do note that you have give card class which is an abstract class but you have not given the concrete implementation class of Card.. Hence if you try to use above code as it is, it will give error as Abstract class can not be instantiated.
So please replace the Card card = new Card(r, s); calls with Your Concrete class constructor and everything will work fine. Thanks!

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