import java.util.*; public class PezCandy { private Stack s = new Stack(); private static int SIZE = 15; //original number of candies in Pez candy container private static String COLORS[] = {"red", "green", "blue", "yellow", "orange"}; private static String FAVORITE_COLOR = "orange"; //Fill Pez candy with candy of arbitrary colors. public void fill() { for (int i = 0; i < SIZE; i ++) { int r = (int) (Math.random()*COLORS.length); s.push(COLORS[r]); } }//fill() //--------------------------------------- public void displayContents() { Stack s2 = new Stack(); System.out.println("\nContents of Joe's Pez candy: "); while ( !s.empty() ) System.out.print( s2.push(s.pop()) + " "); //now candy is stored in stack s2 in the reverse order. Move it back to original stack while ( !s2.empty() ) s.push(s2.pop()); }//displayContents() //---------------------------------------- //This method simulates eating the favorite candy by removing //the candy with the favorite color from the stack public void eatFavoriteCandy() { }//removeFavoriteCany() //---------------------------------------- public static void main(String [] args) { PezCandy candy = new PezCandy(); candy.fill(); candy.displayContents(); candy.eatFavoriteCandy(); candy.displayContents(); }//main() }//class