Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design and implement a class called Card that represents a standard playing card. Each card has a suit and face value. For your design, include

Design and implement a class called Card that represents a standard playing card. Each card has a suit and face value. For your design, include a UML Class diagram. Note that you need to include the two constructors in the methods section (i.e., they must be coded). Represent the faces/ranks of Ace through King as 1 through 13 and the suits as 1 through 4. You need two constructors: one that receives a face/rank value and suit value as parameters, plus the default constructor where these values are randomly generated. The face/rank and suit must both have appropriate get_ and set_ methods for the numeric values plus a get_ method for the textual equivalent (e.g., getFace() might return 13 while getFaceText() would return "King"). Your toString method should return a nice representation of the values like "Ace of Spades" or "Nine of Hearts." Include a test driver that creates five random cards (i.e., uses the default constructor) and outputs them. Then creates five more cards of specific face/rank and suit values (i.e., uses the first constructor) and outputs them. The specific cards should include two with 'boundary' values: for example, face 1, suit 1 and face 13, suit 4. The final card should use invalid face and suit values, such as 15 and 5. You should not need to prompt the user for anything, just hard-code the calls like: Card card6 = new Card(1,1). Please ensure that 10 cards show up in the testing screen and not 9.

In Java Pls.

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

Database Processing Fundamentals Design And Implementation

Authors: David M. Kroenke

5th Edition

B000CSIH5A, 978-0023668814

More Books

Students also viewed these Databases questions

Question

Describe the types of power that effective leaders employ

Answered: 1 week ago

Question

Describe how leadership styles should be adapted to the situation

Answered: 1 week ago