diff --git a/SimplePriorityQueue/src/testat_g11/SimplePriorityQueue.java b/SimplePriorityQueue/src/testat_g11/SimplePriorityQueue.java index 4969696..384bdf3 100644 --- a/SimplePriorityQueue/src/testat_g11/SimplePriorityQueue.java +++ b/SimplePriorityQueue/src/testat_g11/SimplePriorityQueue.java @@ -49,8 +49,22 @@ public class SimplePriorityQueue implements IPriorityQueue // Methode incrementAge() erhöht (Siehe Ticket im Paket testat_g11) @Override public T poll() { - // TODO Auto-generated method stub - return null; + if (size == 0) { + return null; + } + T tick = tickets[0]; + + for (int i = 1; i < size; i++) { + if (prioDet.calculate(tickets[i]) > prioDet.calculate(tick)) { + tick.incrementAge(); + tick = tickets[i]; + } else { + tickets[i].incrementAge(); + } + } + + remove(tick); + return tick; } // True: Ticket t ist enthalten, false sonst