Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CS 251 Program 04 Due: Monday, October 9th Main topics: Writing Classes Declaring / Using Instance Variables Writing Instance Methods Accessors and Mutators Constructors public

image text in transcribed

image text in transcribed

CS 251 Program 04 Due: Monday, October 9th Main topics: Writing Classes Declaring / Using Instance Variables Writing Instance Methods Accessors and Mutators Constructors public vs private static vs non-static Program Specification You are to write a Class Deck which emulates a full deck of playing cards. That is 4 suits (Clubs, Spades, Hearts, and Diamonds) and 13 ranks (Ace, 2, 3, 4, 5, 6. 7, 8, 9, Jack, Queen, King) in each suit. This of course makes for a total of 52 playing cards in the deck. Mandatory Instance variables private Card[] deck = new Card [52] ; private int cardsDealt; Mandatory Instance met hods: public Deck) // constructor // set each element of deck to a unique Card object, // and sets cardsDealt to zero. public int getCardsDealt) // accessor // return the value of cardsDealt private void setCardsDealt (int cardsDealt /mutator // sets cardsDealt specified value (cardsDealt) public boolean emptyDeck) // returns wheather or not all the cards in dechk // have already been dealt (cardsDealt52) public void collectCards) // set cardsDealt to zero public void collectCards(int cardCnt) // decrement cardsDealt by cardCnt public Card dealCard) // if emptyDeck) is false // returns the card at location cardsDealt in deck, // and increments cardsDealt by1 // else // returns null CS 251 Program 04 Due: Monday, October 9th Main topics: Writing Classes Declaring / Using Instance Variables Writing Instance Methods Accessors and Mutators Constructors public vs private static vs non-static Program Specification You are to write a Class Deck which emulates a full deck of playing cards. That is 4 suits (Clubs, Spades, Hearts, and Diamonds) and 13 ranks (Ace, 2, 3, 4, 5, 6. 7, 8, 9, Jack, Queen, King) in each suit. This of course makes for a total of 52 playing cards in the deck. Mandatory Instance variables private Card[] deck = new Card [52] ; private int cardsDealt; Mandatory Instance met hods: public Deck) // constructor // set each element of deck to a unique Card object, // and sets cardsDealt to zero. public int getCardsDealt) // accessor // return the value of cardsDealt private void setCardsDealt (int cardsDealt /mutator // sets cardsDealt specified value (cardsDealt) public boolean emptyDeck) // returns wheather or not all the cards in dechk // have already been dealt (cardsDealt52) public void collectCards) // set cardsDealt to zero public void collectCards(int cardCnt) // decrement cardsDealt by cardCnt public Card dealCard) // if emptyDeck) is false // returns the card at location cardsDealt in deck, // and increments cardsDealt by1 // else // returns null

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started