Below is the question I need help with It need to be done in
Below is the question I need help with. It need to be done in Java. I need help making the priority queue part of the assignment, if you can add the GUI it will be helpful.
You are to simulate a dispatcher using a priority queue system. New processes are to be entered using a GUI with priority included (numbering should be automatic). Processes are also to be terminated by GUI command. Context switches are to be by command with the cause of the switch being immaterial. Assume only one CPU. Priorities and numbers of processes can be kept small, just big enough to demonstrate the below listed functionality. You may pre-populate the queues initially from a data file. I am looking at the mechanism as you are NOT creating actual processes, just simulating them. Functionality to be provided by you:
1. Priority based Ready Queue(s).
2. Blocked list.
3. Output of complete system status after every context switch showing ready, blocked, and running processes.
You are to turn in your source code, an executable, and PDF screen shots of the output demonstrating the functionality listed above. If you use any data files as initial input, provide them also. They are to be submitted via EMAIL to srizvi@cs.odu.edu. I use Outlook and that program will not accept certain file extensions. Simply modify the extension and I\'ll change it back when I get it. Python Java are the recommended languages to be used.
Solution
package com.journaldev.collections;
public class Customer {
private int id;
private String name;
public Customer(int i, String n){
this.id=i;
this.name=n;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
}
Processing Integer:9
Processing Integer:16
Processing Integer:18
Processing Integer:25
Processing Integer:33
Processing Integer:75
Processing Integer:77
Processing Customer with ID=6
Processing Customer with ID=20
Processing Customer with ID=24
Processing Customer with ID=28
Processing Customer with ID=29
Processing Customer with ID=82
Processing Customer with ID=96
Exception in thread \"main\" java.lang.ClassCastException: com.journaldev.collections.Customer cannot be cast to java.lang.Comparable
at java.util.PriorityQueue.siftUpComparable(PriorityQueue.java:633)
at java.util.PriorityQueue.siftUp(PriorityQueue.java:629)
at java.util.PriorityQueue.offer(PriorityQueue.java:329)
at java.util.PriorityQueue.add(PriorityQueue.java:306)
at com.journaldev.collections.PriorityQueueExample.addDataToQueue(PriorityQueueExample.java:45)
at com.journaldev.collections.PriorityQueueExample.main(PriorityQueueExample.java:25)

