Question
A labeled point has x- and y-coordinates and a string label. Provide a class LabeledPoint with a constructor LabeledPoint(int x, int y, String label) and
A labeled point has x- and y-coordinates and a string label. Provide a class LabeledPoint with a constructor LabeledPoint(int x, int y, String label) and hashCode and equals methods. Two labeled points are considered the same when they have the same location and label. Your class LabeledPoint should implement the Comparable interface. Sort points first by their x-coordinates. If two points have the same x-coordinate, sort them by their y-coordinates. If two points have the same x- and y-coordinates, sort them by their label. Write a tester program that : 1) creates 4 collections of Labeled points: TreeSet, HashSet, Queue, PriorityQueue 2) inserts in each of these collections the followings points: (1,1,"A"), (3,3,"B"), (2,1,"C"), (4,4,"D"), (2,4,"E"), (3,3,"F"), 3) diplays all elements of the collection by using toString() method. NB: To implement LabelelPoint#hashCode() use the static method hash(Object... values) that Generates a hash code for a sequence of input values.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started