Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are to first to write a Class named Card. Card.java A simple class which models a single playing card (from the deck of cards

You are to first to write a Class named Card.

Card.java

A simple class which models a single playing card (from the deck of cards that has been described in Howeworks 1 and 2) by its two defining characteristics, which are its suit and its rank. Your Card class must adhere to the following:

All instance variables must be private

Include the standard public accessors

Include the standard private mutators

You must not set suit nor rank to something that is not in the domain of the mapping that is inherent to your String toString() method. Do nothing when an argument is invalid.

All access of instance data by the other instance methods is made via the accessors and mutators.

Include the standard default constructor By default a Card is the Ace of Clubs.

Include the standard specifying constructor

(g)Contain a method Card clone() which creates and return a reference to a copy of the calling Card object.

Contain a method boolean equals(Card guest) which returns whether or not guest has the same suit and rank as the calling Card object.

Contain a method String toString() which returns a String representation of the calling Card objects suit and rank in some reasonable format.

You are then to write a Class named CardDriver.

CardDriver.java

A simple class which tests Your Card class by carrying out the following actions:

Declare and create an array of Card, of size 52 (A deck).

Fill the deck with the 52 unique playing cards (in any order).

Apply 100 random transpositions of cards to the deck. A transposition:

Generate two random indices (each in the range 0 to 51)

Swap the two cards at these indices.

Display the contents of the deck, from index 0 to index 51.

Find and display the index of the Queen of clubs in the deck.

Sample run(s):

The Queen of clubs was found at location 42

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

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions

Question

=+8. Why is productivity important?

Answered: 1 week ago

Question

=+ 9. What is inflation and what causes it?

Answered: 1 week ago

Question

=+6. What does the invisible hand of the marketplace do?

Answered: 1 week ago