Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Attached Files: PlayingCard.java (1.216 KB) CardDeal.java (958 B) For this assignment, one complete program and one partial program are being provided to you. The PlayingCard

Attached Files:

image text in transcribed PlayingCard.java (1.216 KB)

image text in transcribed CardDeal.java (958 B)

For this assignment, one complete program and one partial program are being provided to you. The PlayingCard program is good as it is. The CardDeal program is like a tester program and you will need make modifications to it.

CardDeal methods:

populateCardDeck() - this method populates an ArrayList with 52 PlayingCard objects (one for each suit/value pair) you find in a deck of playing cards.

outputCardDeck() - the method call is there and the method heading shell is there. Modify this method to output all the PlayingCards which are in the deck ArrayList.

dealHand() - the method call is there and the method heading shell is there. if you look at the hand array in the program, you will see it's set up to accomodate 5 PlayingCard objects. This method is to populate that hand array with 5 distinct PlayingCard objects. It also needs to manage the deck ArrayList of PlayingCard to ensure the same card isn't dealt more than once. Meaning as a PlayingCard is dealt to the hand array it is removed from the deck ArrayList.

showHand() - the method call is there and the method heading shell is there. Modify this method to output the hand array content of 5 PlayingCards.

showRemainingDeck() - the method call is there and the method heading shell is there. Modify this method to output all the remaining PlayingCards which are in the deck ArrayList. This should be one line of code that simply calls one of the other methods.

Attached Files

/** This program is for representing one Card from a fifty-two card deck of playing cards. */ public class PlayingCard { private String suit; private String value; public PlayingCard() { //default no argument constructor for creating a new instance } public PlayingCard(String pSuit, String pValue) { //overloaded constructor to initialize with passes values suit = pSuit; value = pValue; } public String getSuit() { return suit; } public void setSuit(String pSuit) { suit = pSuit; } public String getValue() { return value; } public void setValue(String pValue) { value = pValue; } public String toString() { StringBuffer buf = new StringBuffer(); buf.append("Card: " + getValue() + " of " + getSuit()); return buf.toString(); } public boolean equals(Object obj) { PlayingCard oth; boolean result = false; if (obj instanceof PlayingCard) { oth = (PlayingCard) obj; if (this.getSuit().equals(oth.getSuit()) && this.getValue().equals(oth.getValue())) { result = true; //if all the preceding are true this PlayingCard and oth are equivalent } } return result; } }

Second Attached file

import java.util.ArrayList; public class CardDeal { static String[] values = {"Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"}; static String[] suits = {"Hearts", "Diamonds", "Spades", "Clubs"}; static ArrayList deck = new ArrayList(); static PlayingCard[] hand = new PlayingCard[5]; public static void main(String[] args) { populateCardDeck(); outputCardDeck(); dealHand(); showHand(); showRemainingDeck(); } public static void populateCardDeck() { //populate the deck with PlayingCards for(int s = 0; s 

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

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

ISBN: 0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

How might budget deficits affect long-term economic growth?

Answered: 1 week ago

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago