import java.io.*; import java.util.*; class Assignment implements Comparable { private int priority; //1 means highest priority private String name; //e.g. "CS2312 Assignment", "CS3342 Project" "CS3334 Survey" public Assignment(String name,int priority) { this.priority=priority; this.name=name; } public int compareTo(Assignment other) {return Integer.compare(priority, other.priority);} public String toString() {return name+"(Priority:"+priority+")";} } public class Main { public static void main(String[] args) { PriorityQueue qToDo = new PriorityQueue<>(); qToDo.add(new Assignment("CS3342 Project", 2)); qToDo.add(new Assignment("CS3334 Survey", 1)); qToDo.add(new Assignment("CS2312 Assignment", 1)); System.out.println(qToDo); //order not guaranteed System.out.println(qToDo.remove()); //removed based on priority System.out.println(qToDo.remove()); System.out.println(qToDo.remove()); } }