Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(USE INHERITANCE extends/implements) Part 2 Inheritance, comparable and comparator Part A: Point.java Write a Point class that simulates a 1D point, which has an x

(USE INHERITANCE extends/implements)

Part 2 Inheritance, comparable and comparator Part A: Point.java Write a Point class that simulates a 1D point, which has an x coordinate value. Implement the constructors (both default and overloading), get method, and default toString method.

Part B: Test.java Generate a Point array1 of five 1D points, (1.1, 2.2, 0, 7, 1.1) Sort the 1D point array using the Arrays.sort method by passing your own comparator using anonymous inner class style. 1D points are compared based on their x coordinates. (Print the array after sorting) After, Sort the 1D point array again in reverse order by pass a slightly different comparator using lambda expression style. (Print the array after sorting.)

Sample Output Sort 1D points by x coordinate (ascending order): Point (x): -2.2 Point (x): 0.0 Point (x): 1.1 Point (x): 1.1 Point (x): 7.0 Sort 1D points by x coordinate (descending order): Point (x): 7.0 Point (x): 1.1 Point (x): 1.1 Point (x): 0.0 Point (x): -2.2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

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

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions

Question

6. Are my sources reliable?

Answered: 1 week ago

Question

5. Are my sources compelling?

Answered: 1 week ago