Question: Write the HeapPriorityQueue class from the notes, using your ArrayList implementation as the base ( the List interface is provided ) . We will use

Write the HeapPriorityQueue class from the notes, using your ArrayList implementation as the base (the List interface is provided). We will use this to model and simulate an airline standby list, prioritizing certain passengers.
Make sure your ArrayList is fully implemented; it should be dynamic and have an iterator() and toString().
a. Write the AbstractPriorityQueue class from the notes; it implements the provided PriorityQueue and Entry interfaces. You do not need to include functionality for the default comparator (or the class itself), but you might find it easier to do so anyways.
b. Write the HeapPriorityQueue class, extending AbstractPriorityQueue.
c. Create a Passenger class that stores a (String) passport number, a Fare code, a Flyer status code, and a (Date) timestamp when the Passenger was created. You will have to include java.util. Date; the default Date constructor makes a timestamp at when it was called.
d. Create an enum for Fare, which can be one of Full, Disc, Buddy. Priority is given to passengers in this order. Include a method randomValue () that randomly returns one.
e. Create an enum for FlyerStatus, which can be one of Gold, Silver, Bronze, None. Priority is given to passengers in this order. Include a method randomValue () that randomly returns one.
f. Create a PassengerComparator that compares two Passengers. They are ordered first by Fare code, then Flyer status. If both are the same, the earliest timestamp is ordered first.
Note Enums and Date atready implement Comparable and will be naturally ordered in the correct intended way without modification.
g. In your driver, create a HeapPriorityQueue with Passengers as keys and their passport numbers as values.
I. Add 10 new passengers, whose passport numbers are provided by user input (Scanner) but the fare code and flyer status are randomly chosen. For simplicity only use passport numbers of 24 characters.
ii. Board 5 passengers in priority order (remove highest priority)
iii. Add 5 more passengers in the same way as above.
iv. Board the rest of the passengers in priority order.
Print the details at each step in a format that displays the added/removed passenger details and the current priority queue. Write whatever methods you may need for this.
Write the HeapPriorityQueue class from the notes,

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!