Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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,

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:

  1. Create a class PezCandy in which you implement an array-based stack
  2. Create a class PezCandyDriver in which you solve the problem as described above
  3. 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
  4. 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

  5. Run the program and capture a snapshot showing the initial content of the Pez container, and the content after you ate all red candies.
  6. If you implement all the required methods properly, the driver program should generate outputs similar to the following:

outcome
image text in transcribed

The original content of the Pez container Candy stack: pink red blue green blue red yellow blue yellow blue green red I am just eating a red candy!!! I am just eating a red candy!!! I am just eating a red candy!!! The spare dispenser Candy stack: green blue yellow blue yellow blue green blue pink The content of Pez container after eating red candies Candy stack: pink blue green blue yellow blue yellow blue green Press any key to continue

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

Computer Performance Engineering 10th European Workshop Epew 2013 Venice Italy September 17 2013 Proceedings

Authors: Maria Simonetta Balsamo ,William Knottenbelt ,Andrea Marin

2013 Edition

3642407242, 978-3642407246

Students also viewed these Programming questions