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 with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions