Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class call Card.java , it should contain at least 2 variables one is suit(Spade , Heart, Diamond, Club) and the other one is

Create a class call Card.java, it should contain at least 2 variables one is suit(Spade , Heart, Diamond, Club) and the other one is rank(1~13). Please new 26 card instances using the followings:

// You should know how to use the following code to achieve what you want.

import java.util.*;

Card cards[] = new Card[26];

String suit[] = {Spade , Heart, Diamond, Club};

Random r = new Random[52];

for(int i = 0; i < cards.length; i++){

cards[i] = new Card(r.nextInt(13)+1, suit[r.nextInt(100)%4]);

//You should design the above constructor inside the Card.java

}

After this, please sort the array cards. To compare two cards, first of all you have to compare their ranks. If they have the same rank, you have to then compare their suit (Spade > Heart > Diamond, > Club). If two cards are equal to each other, just put them together. Show the array just sorted

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

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

Recommended Textbook for

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

Students also viewed these Databases questions

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago