Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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 methods public Deck) // constructor // set each element of deck to a unique Card object, // and sets cardsDealt to zero public int getCardsDealt O // 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 deck // have already been dealt (cardsDealt 52) 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 by 1. // else // returns nul1 public void shuffleDeck) // apply 100 random card swaps within deck public void shuffleDeck(int swapCnt) // apply swapCnt random card swaps within deck You are also to write a Driver Class DeckDriver to test your Deck class. Mandatory Functionalit Your driver class must minimally print all the cards in the deck in the random order that they are "dealt". Such as in Programs 1, 2, and 3 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 methods public Deck) // constructor // set each element of deck to a unique Card object, // and sets cardsDealt to zero public int getCardsDealt O // 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 deck // have already been dealt (cardsDealt 52) 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 by 1. // else // returns nul1 public void shuffleDeck) // apply 100 random card swaps within deck public void shuffleDeck(int swapCnt) // apply swapCnt random card swaps within deck You are also to write a Driver Class DeckDriver to test your Deck class. Mandatory Functionalit Your driver class must minimally print all the cards in the deck in the random order that they are "dealt". Such as in Programs 1, 2, and 3

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

Recommended Textbook for

DB2 9 For Linux UNIX And Windows Advanced Database Administration Certification Certification Study Guide

Authors: Roger E. Sanders, Dwaine R Snow

1st Edition

1583470808, 978-1583470800

More Books

Students also viewed these Databases questions

Question

=+How should it be delivered?

Answered: 1 week ago

Question

=+4 How does one acquire a global mindset?

Answered: 1 week ago