The purpose of this project is to give you experience with Stacks and using them. In this project, you'll create a stack of 52 cards in a random order, and print them out.
For this project, you will create two classes:
Stack.Java is to be implemented like we did together on 3/24 and 3/26. You will create a private array in Stack that holds any values given to the stack. However, this time you will make it an array of Strings. Your Stack class must have the following: a Push() function, a Pop() function, and an IsEmpty() function. Push will return nothing, instead adding a String to the array. Pop() will remove and return the "top-most" String element in the stack, which should be the last item added to the array. IsEmpty() will return a bool for whether the array is empty or not. No System.out.print messages of any kind are allowed in the Stack class!
In Main.java, your goal is to create a stack of String objects and print them out. Create an array of Strings such that each element in the array is the name of a card. Create an ArrayList using this array.
Create an empty Stack that can hold 52 elements. Using the java.util.Random package, use the Random function to randomly add elements from the ArrayList to the stack. As you add an element to the stack, remove it from the ArrayList. This way when the Stack is full, the ArrayList will be empty.
From here, Loop through and print all values from the stack. Use IsEmpty to check whether the Stack is empty. Use the return value from Pop() to get the top most value in order to print each value.
Sample Program Run (note there is no user input)
Cards in Arraylist:
Ace of Clubs
Ace of Diamonds
Ace of Hearts
Ace of Spades
2 Clubs
2 Diamonds
(...this should print like this all the way to the King of Spades).
Cards in Stack:
10 Hearts
Jack of Diamonds
3 Spades
8 Clubs
10 Clubs
Ace of hearts
(...these should randomly print like this, and iterate through all 52 cards in stack.).