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, create

Design and implement a class called Card that represents a standard playing card. Each card has a suit and face value. For your design, create a UML Class diagram similar to Figure 5.5 on page 180 of the textbook. Note that you need to include the two constructors in the methods section (they must be coded).

Hints: Represent the faces/ranks of Ace thru King as 1 thru 13 and the suits as 1 thru 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.

Write 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: i.e. 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);

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 Systems For Advanced Applications 15th International Conference Dasfaa 2010 Tsukuba Japan April 2010 Proceedings Part 1 Lncs 5981

Authors: Hiroyuki Kitagawa ,Yoshiharu Ishikawa ,Wenjie Li ,Chiemi Watanabe

2010th Edition

3642120253, 978-3642120251

More Books

Students also viewed these Databases questions