Question: Your class should have two constructors: - One that takes an int and a String. The integer ( 2 through 1 4 ) is used
Your class should have two constructors: One that takes an int and a String. The integer through is used to set the card value. through are obvious. Jack has value Queen has value King has and Ace has The String sets the suit. To set the suit, look at the first letter of the argument, ignoringupperlowercase and if it is shcd then set the suit accordingly Spades Hearts, Clubs,Diamonds Another constructor takes a String and parses it to set the card value and suit. If the firstcharacter in the string is through or J Q K or A ignore upperlowercase then set the cardvalue in the obvious way. If the first character is then the second character must be toindicate a card value of The following character should be shcd to specify the suit.Accept either uppercase or lowercase letters to set the suit. Any following characters in theinput parameter can be ignored. If there is any error in the input to the constructor, the card value should be set to and the suitshould be set to ERROR What are errors? Values not in the range from through or notjqk or a for the second constructor or suit letters other than s h c dIn addition to the constructors, please add the following methods: Value: returns the cards value as an integer in the range from through Suit: returns the cards suit as a String. The suit should be represented as a single capitalletter: SHC or D A method called toString that returns a String showing the value and then the suit,with no space between them. However, instead of printing for Jack, for Queen, etcinstead print J for Jack, Q for Queen,
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
