priority
parent
6868878b50
commit
2a28e3a16e
|
@ -0,0 +1,14 @@
|
|||
package Queue;
|
||||
|
||||
public enum Prioritaet {
|
||||
GOLD(1),SILBER(2),BRONZE(3);
|
||||
private final int value;
|
||||
|
||||
Prioritaet(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package Queue;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.util.*;
|
||||
|
||||
public class Reklamation implements Comparable<Reklamation> {
|
||||
String kundennr;
|
||||
Date datum;
|
||||
String beschreibung;
|
||||
Prioritaet prio;
|
||||
|
||||
public Reklamation(String string, Date datum, String b, Prioritaet prio) {
|
||||
this.kundennr = string;
|
||||
this.datum = datum;
|
||||
this.beschreibung = b;
|
||||
this.prio = prio;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Reklamation other) {
|
||||
// Sortierung nach Priorität
|
||||
if (this.prio.equals(other.prio)) {
|
||||
// Bei gleicher Priorität nach Datum
|
||||
return this.datum.compareTo(other.datum);
|
||||
} else {
|
||||
return this.prio.compareTo(other.prio);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
PriorityQueue<Reklamation> reklamationen = new PriorityQueue<>();
|
||||
reklamationen
|
||||
.add(new Reklamation("Lisa Mayer", new Date(1234567890), "Handybildschirm kaputt", Prioritaet.BRONZE));
|
||||
reklamationen.add(new Reklamation("Hanna Montana", new Date(1234567900),
|
||||
"20 Laptops müssen vor Sa repariert werden", Prioritaet.GOLD));
|
||||
reklamationen.add(new Reklamation("Herbert Grönemayer", new Date(1234567910), "braucht neues Softwareupdate",
|
||||
Prioritaet.SILBER));
|
||||
reklamationen.add(new Reklamation("KSI", new Date(1234567920), "neue Iphone Bestellung nicht angekommen",
|
||||
Prioritaet.BRONZE));
|
||||
|
||||
for (Reklamation reklamation : reklamationen) {
|
||||
System.out.println(reklamation.kundennr + " - " + reklamation.beschreibung + " (" + reklamation.prio + ")");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue