Question: For this assignment you will need to write and submit two java programs: 1. PlayingCard The UML diagram for this class is displayed below. The

For this assignment you will need to write and submit two java programs:

1. PlayingCard The UML diagram for this class is displayed below. The PlayingCard class will be a java program for representing an individual playing card from a deck of cards. For example, the jack of spades represents one instance of a PlayingCard with suit = Spades and value = Jack.

!!! NOTE: you do not need to write the equals method as shown in the UML diagram below.

2. PlayingCardTester Much like the Student and Student_Tester classes looked at in class today. This class will be the one we execute(ie. contains the main method we execute). It will create instances of PlayingCard objects, calls methods on the PlayingCard class, and finally output each PlayingCard's content through calls to it's toString() method.

3. The PlayingCardTester must do the following at a minimum:

Creates 3 separate instances of PlayingCard objects

Calls the setSuit and setValue method for each of the 3 PlayingCards or uses an over loaded constructor for populating the suit and value attributes.

Outputs the variable values for each of the 3 PlayingCards (ie. Calls the toString() method for each PlayingCard).

Calls and outputs the results of calling a given PlayingCard's equals method passing it another PlayingCard.

!!! NOTE: none of your methods will be static, why? So we can create instances of PlayingCard s!!!

1. The equals method:

public boolean equals(Object obj) {

boolean result = false;

if (obj instanceof PlayingCard) {

PlayingCard objCard = (PlayingCard)obj;

if (getSuit().equals(objCard.getSuit()) &&

getValue().equals(objCard.getValue())) {

result = true;

}

}

return result;

}

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!