Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

In Java Last time the code : Card c = Card.getCard(card.substring(0, 1), card.substring(1)); didnt work Please show a different approach to this Thanks Create Rank

image text in transcribed

In Java

Last time the code : Card c = Card.getCard(card.substring(0, 1), card.substring(1)); didnt work

Please show a different approach to this

Thanks

Create Rank and Suit enum types and use them below. Create an immutable Card class with the following interface \begin{tabular}{l} \hline public Rank getRank(); \\ public Suit getSuit(); \\ public int getCribCount(); \\ public String toString(); \\ public static Card getCard(Rank r, Suit s); \\ public static Card getCard(int i); \\ \hline \end{tabular} The tostring () method should return a string like "9S" for the nine of spades. Tens can be monds, hearts and spaces, $(\u2663)(\u2662)(\u2661) and (\u2660) are also acceptable. Your Card class needs constructors, and internal private state variables. The static getCard mehtods should just call these constructors, as in \begin{tabular}{lll} \hline public static Card getCard(Rank r, Suit s) & { return new Card(r,s) ;} \\ public static Card getCard(int i) & { return new Card(i) ; } \\ \hline \end{tabular} The Card(int i ) should take a number 0i

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_2

Step: 3

blur-text-image_3

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

How Do I Use A Database Research Tools You Can Use

Authors: Laura La Bella

1st Edition

1622753763, 978-1622753765

More Books

Students explore these related Databases questions