Program


Create an application that uses a "PriorityQueue" to perform the following

Uses the constructor that receives a "Comparator" object as an argument
Stores 5 "Time1" objects using the "Time1" class shown in Fig. 8.1 on page 317. The class must be modified to implement the "Comparator" interface
Displays the "Universal Time" in priority order

Note: To determine the ordering when implementing the "Comparator" interface, convert the time into seconds (i.e., hours * 3600 + minutes * 60 + seconds), smaller values infer higher priority)

2)Create an application that provides a solution for problem 20.8 In addition to requirements specified in the description. The class must satisfy the following

Default Constructor
Two argument constructor for data used to initialize "first" and "second"
"toString" method for displaying the "first" and "second" data elements
Creates a "Comparator" object (to be used by the sort method; i.e. create an instance of a class that implements the interface [must override "compare" and "equals" methods])

The application must create an ArrayList of 5 Pair objects and then display the contents in sorted order largest to smallest, based on the method used to compare "Pair" objects. The class only supports types that extend Number. Assume the "Pair" objects contain x, y coordinates. Therefore calculate the distance from a 0,0 coordinate to detrmine the sorting order (i.e., ascending, smallest distance to largest distance).

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Program
Reference No:- TGS0546612

Expected delivery within 24 Hours