Task 1:

The following shows a deck of 52 playing cards: see image.

- Four suits (Spade, Heart, Diamond, and Club (in that order). We usually use characters 'S', 'H', 'D', and 'C' to denote the 4 suits.

- Rank values from Two, Three .....Ten, Jack, King, Queen, and Ace (in that order). We usually use characters '2', '3', '4', ... , '9', 'T', 'J', 'Q', 'K', 'A' to denote the rank values.

Define two enum tyeps, one for Suit whose constants (Spade, Heart, Diamond, and Club) take one character parameter (the values as quoted above, 'S', 'H' etc); and one for Rank whose constants (Two, Three etc) take one character parameter (the values as quoted above, '2', '3' etc). see image.

Suggest and implement a class called PlayingCard according to the following UML diagram: see image.

The main method will be stored in a class called Assignment_1.

The following UML shows what you have to do in the main method: see image.

The duty of the main method is simple. You construct an ArrayList of 52 (MAXD) playing cards by call the method deckOf Cards to achieve the target; and display them (by calling the printDeck method to do this task). Note that each set of playing card has 13 (MAXC) of spades, hearts, diamonds and clubs.

The next duty of this assignment is to transfer all the objects stored in the ArrayList playing cards to an array of playing cards (invoke list ToArray method). During the transfer, you need to have new objects to be stored in the array i.e. using the copy constructor of PlayingCard; and print this array (by calling the printDeck method to do this task). Note that you have two overloaded printDeck method.

Final task is to shuffle (the shuffle method) the array. You are not allowed to use the shuffle method defined in the Arrays class. What you will do in the shuffle method is to generate a positive integer k (reasonable value); and you need to shuffle the cards k times. To do this, you generate two integers i and j, and swap the playing card i and the playing card j.

Upon execution of your program, the following will be displayed: see image.

The following brief UML diagram shows the relationship between all the classes designed by you: see image.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.