Question: 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

 In Java Last time the code : Card c = Card.getCard(card.substring(0,

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

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!