Stack of Biscuits solution


Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment


5/5 - (1 vote)

Stack of Biscuits

The objective of this assignment is to allow you to work with the Stack data structure and explore the idea of first-in, last-out (FILO) servicing.

Imagine that you’re visiting a local all-you-can-eat breakfast bar; among the many items on the bar is a pan of biscuits. Your task is to simulate the biscuit pan with a computer program. Note that when new biscuits are added to the pan, they’re always added to the top (the worker just dumps new biscuits on top of the old biscuits); also note that whenever someone takes a biscuit to eat, they pick the top-most biscuit. Thus we’ve got a stack (first-in, last-out) and the bottom-most biscuit is always the oldest. For sake of simplicity, imagine that the pan only allows you to select a “top” biscuit (i.e. you can’t pick among many).

Your task is to utilize a stack collection. Your program should allow the user to add a biscuit, remove a biscuit, 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 biscuit “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 (pop) a biscuit if the pan is empty

·         Displaying the status of the stack should show how many biscuits are in the stack and the “age” of the topmost biscuit

·         Use theStackclass 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 theDateclass