Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1: Write a c++ code that will generate random cards until all the different face cards have been seen for a given suit (i.e.,

Part 1: Write a c++ code that will generate random cards until all the different face cards have been seen for a given suit (i.e., "Jack", "Queen", and "King"). then print a table showing how many cards of each suit and rank you were dealt along the way. Flag the suit that caused termination by adding "**" at the end its output line.

Part 2: Write the next c++ code and have it keep track of the order in which a card rank is observed for each suit. You do this by inserting the cards at the back of linked lists, using one list for each suit. The exception applies: each time a rank is seen again, the card gets moved to the front of the list. When the stopping criterion from Prog2a is encountered, break the infinite-loop and print the contents of each linked list to stdout as shown below. Add an array of linked lists: the length of the array is fixed at 4 like before, while the length of each linked list varies from suit to suit. Each new card is added to the appropriate list thru use of an insert() function. Declare a list class based on a single linked list. The list class needs to define a private node datatype, and it must include a constructor for properly initializing an empty list, a destructor for deallocating all the nodes in a list as well as the list itself, and the mentioned insert function which works as described next; no other list class functions are needed. Overload operator<<() used by ostream and have it print the contents of the list. Since access is needed to private data members, make the overloaded output operator a friend of the list class. See the code handouts for how to set this up.

EXAMPLE OUTPUT:

Code 1:

 Clubs : 1 1 1 3 0 1 1 1 0 2 2 0 2 Diamonds : 3 1 2 0 2 0 1 1 2 2 1 2 2 ** Hearts : 1 3 1 1 1 1 2 0 0 3 3 0 0 Spades : 0 1 0 1 2 2 0 0 1 0 1 1 0 

Code 2:

 Clubs : 10 6 Queen King 9 Jack ** Diamonds : Jack 9 6 Ace 3 8 Hearts : 9 3 King 7 Jack Spades : Queen Ace Jack 

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

Advances In Spatial Databases 2nd Symposium Ssd 91 Zurich Switzerland August 1991 Proceedings Lncs 525

Authors: Oliver Gunther ,Hans-Jorg Schek

1st Edition

3540544143, 978-3540544142

More Books

Students also viewed these Databases questions

Question

=+professionalism and competency in handling global HR issues?

Answered: 1 week ago