Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using a GUI create work with the Stack data structure and first-in, last-out. Imagine that you're visiting a local all-you-can-eat cookie bar. Simulate the cookie
Using a GUI create work with the Stack data structure and first-in, last-out. Imagine that you're visiting a local all-you-can-eat cookie bar. Simulate the cookie pan with a computer program. Note that when new cookies are added to the pan, they're always added to the top (the worker just dumps new cookies on top of the old biscuits); also note that whenever someone takes a cookie to eat, they pick the top-most cookie. Thus, we've got a stack (first-in, last-out) and the bottom-most cookie is always the oldest. Utilize a stack collection. Your program should allow the user to add a cookie, remove a cookie, and print the status of the stack. The stack should store the time in which the biscuit was added; and when a biscuit is removed, the program should display how long the cookie "lived" in the pan (i.e. the difference from now to when it was added to the pan). Important items to consider: Don't allow the user to remove a cookie if the pan is empty Displaying the status of the stack should show how many cookies are in the stack and the "age" of the topmost cookie Use the Stack class to make your job a LOT easier (otherwise, you must implement the stack class yourself) To get the time in Java, import java.util." and then make use of the Date class
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started