Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

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

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions

Question

Understand how emergent change occurs.

Answered: 1 week ago