Instructor: Todd Dole
This assignment provides practice in using classes and objects.
For this assignment, you will create a new program with a class called CardGame, saved as CardGame.java
In this program, we will create a deck of cards and then pick a random card from the deck.
Within the main class, create a public static class called Card, with two String attributes: faceValue and Suit.
In your main method, create an array of Cards, size 52. Then fill the array with a standard deck of playing cards, "2" through "Ace" for the faceValue, and "Clubs", "Diamonds", "Hearts" and "Spades" for the Suit.
You can do this using 52 lines of code, one for each card, or if you get creative, you could use for loops to make the code much shorter.
(Hint: you can use the following code to convert an integer to a String:
int num = 42;
String str = Integer.toString(num);
Once you have your array filled, you will pick a random index between 0 and 51 using the following code:
int randomCard = (int)(Math.random() * 52);
finally, display the card's faceValue and Suit at that index:
Choosing a random card from the deck:
You drew a Seven of Hearts!
Upload your solution to the assignment in Canvas.