commit cc1bf91aa24c3131790fecb061728ce68bb48532 parent 7a6deafd2c12896eef49de3d0dd1b3b269a6f883 Author: William Lindholm <william_lindholm@outlook.com> Date: Mon, 20 Feb 2023 18:29:42 +0100 Added comments Diffstat:
| M | OOP2023_a22willi_a21liltr_assignment3/src/breakRoom/CoffeeQueue.java | | | 19 | +++++++++++++++++++ |
1 file changed, 19 insertions(+), 0 deletions(-)
diff --git a/OOP2023_a22willi_a21liltr_assignment3/src/breakRoom/CoffeeQueue.java b/OOP2023_a22willi_a21liltr_assignment3/src/breakRoom/CoffeeQueue.java @@ -5,18 +5,37 @@ import java.util.concurrent.ConcurrentLinkedQueue; public class CoffeeQueue { private ConcurrentLinkedQueue<Worker> coffeeQueue; + /** + * Constructor, + * creates a new coffeeQueue where workers + * can queue to get their fill of coffee. + */ public CoffeeQueue() { coffeeQueue = new ConcurrentLinkedQueue<Worker>(); } + + /** + * Add worker to queue. + * @param w The worker to add. + */ public void enQueue(Worker w) { coffeeQueue.add(w); } + + /** + * Removes worker from the queue. + * @return returns the removed worker. + */ public Worker deQueue() { return coffeeQueue.remove(); } + /** + * get the ammount of workers currently queuing for coffee. + * @return size of coffeeQueue. + */ public int getSize() { return coffeeQueue.size(); }