Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write the code please CS 251 Program 04 Main topics: Writing Classes Declaring /Using Instance Variables Writing Instance Methods Accessors and Mutators Constructors public vs

write the code please image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
CS 251 Program 04 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 Cles 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 cardaDealt; Mandatory Instance methods public Deck() // constructor // set each element of deck to a unique Card object, // and sets cardsDealt to zero. public int getCard Dealto // accessor // return the value of card Dealt. private void set Card Dealt(int cardsDealt) // mutator // sets card Dealt specified value (cardsDealt) public boolean in EmptyDeck // returns wheather or not all the cards in deck // have already been dealt (cards Dealt -- 52). public void collectAllCards // set cardaDealt to zero. public Card deal Card // if exptyDeck() is false ... // returns the card at location card Dealt in deck, // and increments cardaDealt by 1. // else // returns null public void shuffleDeck // apply 100 random card avaps within deck public void shufflebeck(int svapCnt) // apply swapCut random card swaps within deck You are also to write a Driver Class Deckriver to test your Decks Mandatory Functionality Your driver class must minimally peint all the cards in the deck in the random order that they are dealt". Such as in Programs 1, 2 and 3. Rules and Requirements All access of the Instance variable cardsDealt, by the other instance methods is made via its accor and mutator Notes and Hint: 1. You will need to copy your Card.java ble (from Program 3) into your working directory / project in order to compile your deck class 2. You should be able to re-use mach of your methods code from Programs 1, 2 od 3 3. You should be able to re-write your driver les from Program 3 into your driver cars with minimal modification / effort Sample run(s) Submission: 1. Use your web browser to open https://wwm.edu 2. Select Current Students from the top member 3. Select Can from the drop down the 4. Login to Canvas 5. Click on the COMPSCI 251-401 block 6. Click on Assements 7. Click on Program 01 in the left center of the current window 8. Click the Submit Assignment button in the right top of the current window 9. Click the Browse button in the left center top of the current window 10. Use the File Upload pop-up window to find the file you wish to submit 11. Click on this file name in the right panel of the File Upload pop-up window 12. Click the Open button in the File Upload pop-up window 13. Click the Add button in the bottom right top of the Submit File pop-up window 14. Click the Submit Assignment button in the left bottom of the current window CS 251 Program 04 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 cardaDealt; Mandatory Instance methods: 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 setCards Dealt(int cardsDealt) // mutator // sets cardsDealt specified value (cardsDealt) public boolean isEmptyDeck() // returns wheather or not all the cards in deck // have already been dealt (cards Dealt - 52). public void collectAllCards() // set cardsDealt to zero. public Card dealCard() // if emptyDeck is false ... // returns the card at location cardeDealt in deck, // and increments cardsDealt by 1 // else... // returns null public void shuffleDeck() // apply 100 random card swaps vithin deck public void shuffleDeck(int swapCnt) // apply swapCut random card swaps within deck You are also to write a Driver Class DeckDriver to test your Deck class. Mandatory Functionality: 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. Rules and Requirements: All access of the instance variable cardaDealt, by the other instance methods is made via its accessor and mutator. Notes and Hint: 1. You will need to copy your Card.java file (from Program 3) into your working directory / project in order to compile your deck class. 2. You should be able to re-use much of your methods code from Programs 1, 2, and 3. 3. You should be able to re-write your driver class from Program 3 into your driver class with minimal modification / effort. Sample run(); Submission: 1. Use your web browser to open: https://uum.edu 2. Select Current Students from the top menu bar 3. Select Canvas from the drop down mem 4. Login to Canvas 5. Click on the COMPSCI 2512401 block 6. Click on Assignments 7. Click on Program 04 in the left center of the current window 8. Click the Submit Assignment button in the right top of the current window 9. Click the Browse button in the left center top of the current window 10. Use the File Upload pop-up window to find the file you wish to submit 11. Click on this file name in the right panel of the File Upload pop-up window 12. Click the Open button in the File Upload pop-up window 13. Click the Add button in the bottom right top of the Submit a File pop-up window 14. Click the Submit Assignment button in the left bottom of the current window

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

Intelligent Information And Database Systems 6th Asian Conference Aciids 2014 Bangkok Thailand April 7 9 2014 Proceedings Part I 9 2014 Proceedings Part 1 Lnai 8397

Authors: Ngoc-Thanh Nguyen ,Boonwat Attachoo ,Bogdan Trawinski ,Kulwadee Somboonviwat

2014th Edition

3319054759, 978-3319054759

More Books

Students also viewed these Databases questions