Hier mal ein paar Testcases. Als Anhang gibts die Testcases zum Selbstprobieren
Habt ihr noch irgendwelche anderen Fälle beachtet?
--- Create queue ---
[
[ Empty: true, Size: 0, MaxPriority: -2147483648
--- Fill queue with some values ---
[ (Hallo|100)(Feueralarm|50)(Pupsen|1)
[ Empty: false, Size: 3, MaxPriority: 100, MaxPriorityValue: Hallo
--- Fill queue with other values ---
[ (Test|312)(Hallo|100)(Feueralarm|50)(Test|12)(Pupsen|1)(Minus|-20)
[ Empty: false, Size: 6, MaxPriority: 312, MaxPriorityValue: Test
--- Enqueue item with exisiting priority ---
[ (Test|312)(Hallo|100)(Kanu|100)(Feueralarm|50)(Test|12)(Pupsen|1)(Minus|-20)
[ Empty: false, Size: 7, MaxPriority: 312, MaxPriorityValue: Test
--- Dequeue some items ---
Dequeue: Test (312)
Dequeue: Hallo (100)
Dequeue: Kanu (100)
[ (Feueralarm|50)(Test|12)(Pupsen|1)(Minus|-20)
[ Empty: false, Size: 4, MaxPriority: 50, MaxPriorityValue: Feueralarm
--- Enqueue items with same priority ---
[ (Feueralarm|50)(Test|12)(Pupsen|1)(1|-13)(2|-13)(3|-13)(Minus|-20)
[ Empty: false, Size: 7, MaxPriority: 50, MaxPriorityValue: Feueralarm
--- Dequeue via priority ---
Dequeue 11: false
Dequeue -13: true
[ (Feueralarm|50)(Test|12)(Pupsen|1)(Minus|-20)
[ Empty: false, Size: 4, MaxPriority: 50, MaxPriorityValue: Feueralarm
--- Enqueue null ---
[ (null|7000)(Feueralarm|50)(Test|12)(Pupsen|1)(Minus|-20)
[ Empty: false, Size: 5, MaxPriority: 7000, MaxPriorityValue: null
--- Iterate through queue and test remove ---
Next: null
Removed!
Next: Feueralarm
Next: Test
Next: Pupsen
Removed!
java.lang.IllegalStateException
Next: Minus
Next: java.util.NoSuchElementException
[ (Feueralarm|50)(Test|12)(Minus|-20)
[ Empty: false, Size: 3, MaxPriority: 50, MaxPriorityValue: Feueralarm
--- Create another queue and fill with some values ---
[ (high|1000)(null|100)(20|20)(nix|-1000)
[ Empty: false, Size: 4, MaxPriority: 1000, MaxPriorityValue: high
--- Add queue 2 to queue 1 ---
Queue 1:
[ (high|1000)(null|100)(Feueralarm|50)(20|20)(Test|12)(Minus|-20)(nix|-1000)
[ Empty: false, Size: 7, MaxPriority: 1000, MaxPriorityValue: high
Queue 2:
[ (high|1000)(null|100)(20|20)(nix|-1000)
[ Empty: false, Size: 4, MaxPriority: 1000, MaxPriorityValue: high
--- Add null-queue to queue 1 ---
java.lang.IllegalArgumentException: Schlange must not be null.
--- Clear queue 1 ---
[
[ Empty: true, Size: 0, MaxPriority: -2147483648
--- Get front-item of empty queue ---
java.util.NoSuchElementException
--- Dequeue from empty queue ---
java.util.NoSuchElementException
Edit: Damit der Anhang funktioniert muss in der Warteschlange.java folgende Methode vorhanden sein:
public String toString() {
// Temporäre Variablen
Iter iter = new Iter();
PriorisiertesElement<WertType> item = null;
String string = "[ ";
// Alle Elemente durchgehen und in String schreiben
while (iter.hasNext()) {
item = iter.next();
string = string + "(" + item.wert() + "|" + item.prioritaet() + ")";
}
// Eigenschaften der Schlange in String schreiben
string = string + "\n[ Empty: " + empty() + ", Size: " + size + ", MaxPriority: " + maxPrioritaet();
// Wenn die Schlange nicht leer ist, weitere Eigenschaften schreiben
if (empty()) {
string = string + "\n";
} else {
string = string + ", MaxPriorityValue: " + front() + "\n";
}
// String ausgeben
return string;
}
Attachment:
Program.java: https://fsi.cs.fau.de/unb-attachments/post_47266/Program.java