Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please write the code CS 251 Program 03 Main topics: Writing Classes Declaring / Using Instance Variables Writing Instance Methods Accessors and Mutators Constructors public

please write the code image text in transcribed
CS 251 Program 03 Main topics: Writing Classes Declaring / Using Instance Variables Writing Instance Methods Accessors and Mutators Constructors public vs private Program Specification: 1. You are to first to write a Class named 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 runkYour Card class must adhere to the following: (a) All instance variables must be privato (b) Include the standard public accessors (c) 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. (d) All access of instance data by the other instance methods is made via the accessors and mutatots. (e) Include the standard default constructor By default a Card is the Ace of Clubs (f) Include the standard specifying constructor () Contain a method Card clone () which creates and return a reference to a copy of the calling Card object (h) Contain a method boolean equals(Card guest) which returns whether or not guest has the same suit and rank as the calling Card object. (1) Contain a method String toString which returns a String representation of the calling Card object's suit and rank in some reasonable format. 2. You are then to write a Cluss named 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). (b) Fill the deck with the 52 unique playing cards (in any order). (e) Apply 100 random transpositions of cards to the deck. A transposition: Generate two random indices (ench in the range 0 to 51) Swap the two cards at these indices. (d) Display the contents of the deck, from index 0 to index 51. (e) 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

Visual Basic 4 Ole Database And Controls Superbible

Authors: Michael Hatmaker, C. Woody Butler, Ibrahim Malluf, Bill Potter

1st Edition

1571690077, 978-1571690074

More Books

Students also viewed these Databases questions