CSC 232 - Introduction to Computer Science II
Lab
5


In each plastic container of Pez candy, the colors are stored in random order. Your little brother Joe only likes the orange ones, so he painstakingly takes out all the candies, one by one, eats the orange ones, and keeps the others in order, so that he can return them to the container in exactly the same order as before - minus the orange candies, of course. Complete the code for a program called PezCandy.java that uses stacks to simulate this process by writing the code for the method eatFavoriteCandy( ). The Pez candy container is assumed to contains originally 15 pieces of candy with possible colors chosen randomly from the set {red, green, blue, yellow, orange}.

When you are done, demonstrate your program to the instructor, hand-in a hard copy of the source code of the method eatFavoriteCandy( ) and upload the whole program to your CSC232 upload folder in a folder called LABS\lab4.