[Solved] Package Practical03vets Import Javautilarraydeque Import Javautilqueue Author Public Class Q37194072

package practical03vets;
import java.util.ArrayDeque;
import java.util.Queue;
/**
*
* @author 彭
*/
public class Wombat {
/**
* @param args the command line arguments
*/
private String name;
private int severity;
private double time;
// default constructor
public Wombat()
{
name = “”;
severity = 0;
time = 0.0;
}
// paramterized constructor
public Wombat(String name, int severity, double time)
{
this.name = name;
this.severity = severity;
this.time = time;
}
// getter and setter methods
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getSeverity() {
return severity;
}
public void setSeverity(int severity) {
this.severity = severity;
}
public double getTime() {
return time;
}
public void setTime(double time) {
this.time = time;
}
@Override
public String toString()
{
return (getName() + “, ” + getSeverity() + “, ” + getTime());
}
public static void main(String[] args){
Queue<Wombat> wQueue = new ArrayDeque<>();
wQueue.add(new Wombat(“Fluffy”, 5, 10.5));
wQueue.add(new Wombat(“Socks”, 10, 11.3));
wQueue.add(new Wombat(“Barry”, 10, 10.8));
wQueue.add(new Wombat(“Jobe”, 3, 12.0));
wQueue.add(new Wombat(“Ginger”, 15, 3.2));
// polling de-queue to print all the Wombats’ details
while(!wQueue.isEmpty())
{
System.out.println(wQueue.poll().toString());//poll移除并返问队列头部的元素
}
System.out.println();
}
}
this is the previous checkpoint, please according to theprevious one
Start o point 2 The Tasks A veterinary clinic may want to process its current Wombat queue in the order of severity, i.e. more severe Wombats (higher severity value) are processed first. A PriorityQueue can be used to automatically sort the queue based on the priority of severity 1. Change the implementation of the woueue variable to be a PriorityQueue. Run you code. You should get an error in the output window similar to Exception in thread “main” java.lang.classCastException: practicalD3vets Wombat cannot be cast to java.lang. Comparable at java.util.PriorityQueue.aiftupComparable (Priorityoueue.java:578) at java.util.PrlorityQueue.siftup (PrlorityQueue.java: 574 at java.util.PrlorityQueue.offer (PriorityQueue.jave:274) at practical03vet. PracticalG3Vet.main (Practica103Vet.java:25) Java Result:1 This error means that Wombat does not implement the comparable interface Make your Wombat class implement the Comparable interface, that is public class Wombat implements Comparable<Wombat> Implement all abstract methods. Implement the compareTo so that the Wombat with the highest 2. severity is given the highest priority (polled from the queue first) Flinders University Page 8 of 10 2019 COMP2741/COMP8741 Practical 3, Checkpoints 17-24 3. Your program should output something similar to below with the original set of Wombats. Add more Wombats to your Wombat queue to test out the ordering of the priority queue Ginger, 15, 3.2 Socks, 10, 11.3 Barry, 10, 10.8 Fluffy, 6, 12.0 Jobe, , 10.5 Show transcribed image text Start o point 2 The Tasks A veterinary clinic may want to process its current Wombat queue in the order of severity, i.e. more severe Wombats (higher severity value) are processed first. A PriorityQueue can be used to automatically sort the queue based on the priority of severity 1. Change the implementation of the woueue variable to be a PriorityQueue. Run you code. You should get an error in the output window similar to Exception in thread “main” java.lang.classCastException: practicalD3vets Wombat cannot be cast to java.lang. Comparable at java.util.PriorityQueue.aiftupComparable (Priorityoueue.java:578) at java.util.PrlorityQueue.siftup (PrlorityQueue.java: 574 at java.util.PrlorityQueue.offer (PriorityQueue.jave:274) at practical03vet. PracticalG3Vet.main (Practica103Vet.java:25) Java Result:1 This error means that Wombat does not implement the comparable interface Make your Wombat class implement the Comparable interface, that is public class Wombat implements Comparable Implement all abstract methods. Implement the compareTo so that the Wombat with the highest 2. severity is given the highest priority (polled from the queue first) Flinders University Page 8 of 10 2019 COMP2741/COMP8741 Practical 3, Checkpoints 17-24 3. Your program should output something similar to below with the original set of Wombats. Add more Wombats to your Wombat queue to test out the ordering of the priority queue Ginger, 15, 3.2 Socks, 10, 11.3 Barry, 10, 10.8 Fluffy, 6, 12.0 Jobe, , 10.5
Expert Answer
Answer to package practical03vets; import java.util.ArrayDeque; import java.util.Queue; /** * * @author 彭 */ public class Wombat… . . .
OR

