Question: Do A01 Exercises 1 & 2: Create the Card Class. 1. Complete the implementation of the provided Card class: a. a constructor that takes two
Do A01 Exercises 1 & 2: Create the Card Class. 1. Complete the implementation of the provided Card class: a. a constructor that takes two String parameters that represent the cards rank and suit, and an int parameter that represents the point value of the card; b. accessor methods for the cards rank, suit, and point value; c. a method to test equality between two card objects; and d. the toString method to create a String that contains the rank, suit, and point value of the card object. The string must be in the following format: rank of suit (point value = pointValue) 2. Once you have completed the Card class, find the CardTester.java file in the Activity1 Starter Code folder (A01). Create three Card objects and test each method for each Card object.
/** * Card.java * * Card represents a playing card. */ public class Card {
/** * String value that holds the suit of the card */ private String suit;
/** * String value that holds the rank of the card */ private String rank;
/** * int value that holds the point value. */ private int pointValue;
/** * Creates a new Card instance. * * @param cardRank a String value * containing the rank of the card * @param cardSuit a String value * containing the suit of the card * @param cardPointValue an int value * containing the point value of the card */ public Card(String cardRank, String cardSuit, int cardPointValue) { /* *** TO BE IMPLEMENTED IN ACTIVITY 1 *** */ }
/** * Accesses this Card's suit. * @return this Card's suit. */ public String suit() { /* *** TO BE IMPLEMENTED IN ACTIVITY 1 *** */ }
/** * Accesses this Card's rank. * @return this Card's rank. */ public String rank() { /* *** TO BE IMPLEMENTED IN ACTIVITY 1 *** */ }
/** * Accesses this Card's point value. * @return this Card's point value. */ public int pointValue() { /* *** TO BE IMPLEMENTED IN ACTIVITY 1 *** */ }
/** Compare this card with the argument. * @param otherCard the other card to compare to this * @return true if the rank, suit, and point value of this card * are equal to those of the argument; * false otherwise. */ public boolean matches(Card otherCard) { /* *** TO BE IMPLEMENTED IN ACTIVITY 1 *** */ }
/** * Converts the rank, suit, and point value into a string in the format * "[Rank] of [Suit] (point value = [PointValue])". * This provides a useful way of printing the contents * of a Deck in an easily readable format or performing * other similar functions. * * @return a String containing the rank, suit, * and point value of the card. */ @Override public String toString() { /* *** TO BE IMPLEMENTED IN ACTIVITY 1 *** */ } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
