Question: Please help, Write in Java I wrote out the attached files Attached Files: PlayingCard.java (1.216 KB) /** This program is for representing one Card from

Please help, Write in Java

I wrote out the attached files

Attached Files:

Please help, Write in Java I wrote out the attached files Attached PlayingCard.java (1.216 KB)

/** 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; } }

Files: PlayingCard.java (1.216 KB) /** This program is for representing one Card CardDeal.java (958 B)

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  

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.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!