VL-Algorithmen/T01/Aufgabe05/ListQueue.java
2024-05-21 14:48:00 +02:00

31 lines
570 B
Java

package T01.Aufgabe05;
import java.util.ArrayList;
/**
* Method to represent a Queue (using a List).
*/
public class ListQueue {
ArrayList<Produkt> queue = new ArrayList<>();
/**
* Method to add a product to the Queue.
*
* @param produkt The product to add.
*/
public void add(Produkt produkt) {
queue.add(0, produkt);
}
/**
* Method to take a product from the Queue.
*
* @return The product taken from the Queue.
*/
public Produkt take() {
Produkt produkt = queue.get(0);
queue.remove(0);
return produkt;
}
}