Question
Create a LinkedPriorityQueue class in Java that inherits from the LinkedQueue class. The LinkedPriorityQueue class implements enqueue differently (that is, it overrides the enqueue method).
Create a LinkedPriorityQueue class in Java that inherits from the LinkedQueue class.
The LinkedPriorityQueue class implements enqueue differently (that is, it overrides the enqueue method). Also since the LinkedQueue class is now being used in inheritance, make its instance variables protected so the child class can access them.
In the LinkedPriorityQueue class the generic type parameter declaration will need to change to T extends Comparable. Also include a remove method in your LinkedPriorityQueue class. This method should receive a generic parameter, T, and uses the equals method to match this parameter with the node in the priority queue that contains this information. Youll also need to create a Patient class, that implements the Comparable interface, and holds the patients name and the priority assigned to their injury (10 = extremely severe 1 = mild).
The compareTo method will use the priority to determine <, ==, or >. (Simplest way is to subtract the priorities and return that value). The Patient class will also need to implement the equals method, for use in the remove code, and should use the patients name as the basis for the comparison (since the name is a String, use the equals method from the String class). A patient leaves the priority queue because the wait is taking too long or theyve succumbed to their injury. Test your LinkedPriorityQueue class by adding Patient objects according to their priority (highest priority appears first in the queue).
Be sure to add the objects in random order by their priority. Print out the queue after youve added about 7 patients. Then try removing a few patients, and adding a few more. Print out the final queue. (Updated question, language is Java, sorry I forgot to mention that!)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
![blur-text-image](https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-text-image.webp)
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
![blur-text-image](https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-subtext-image.webp)
Step: 3
![blur-text-image](https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-subtext-image.webp)
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started