You may like the Pez candies and the wonderful dispensers that can be customized in so many
Fantastic news! We've Found the answer you've been seeking!
Question:
You may like the Pez candies and the wonderful dispensers that can be customized in so many ways. In each plastic container of Pez candy, the candies are of different colors, and they are stored in random order. Assume that you like the red candies only. Take a Pez dispenser, take out all candies one by one, eat the red ones, and put the others in a spare container you have at hand. Return the remaining candies in the initial container.
Your Tasks:
- Create a class PezCandy in which you implement an array-based stack
- Create a class PezCandyDriver in which you solve the problem as described above
- Create an algorithm showing how you take out the candies, eat the red ones, and put them back in the container, in the original order. Place the algorithm, as a comment in the top of your PezCandyDriver file
- Use an initial Pez dispenser with 12 candies, in which the colors of the candies are randomly chosen from: red, yellow, green, pink, blue.
????Hints
Use integer values associated with each color, and randomly generate the integer values.
Hints
- Run the program and capture a snapshot showing the initial content of the Pez container, and the content after you ate all red candies.
- If you implement all the required methods properly, the driver program should generate outputs similar to the following:
outcome
Posted Date: