diff --git a/2Semester/src/Queue/Prioritaet.java b/2Semester/src/Queue/Prioritaet.java new file mode 100644 index 0000000..f937f2e --- /dev/null +++ b/2Semester/src/Queue/Prioritaet.java @@ -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; + } +} diff --git a/2Semester/src/Queue/Reklamation.java b/2Semester/src/Queue/Reklamation.java new file mode 100644 index 0000000..4c7b18d --- /dev/null +++ b/2Semester/src/Queue/Reklamation.java @@ -0,0 +1,48 @@ +package Queue; + +import java.sql.Date; +import java.util.*; + +public class Reklamation implements Comparable { + 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 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 + ")"); + } + } + +}