Question: 1 ,9 7.(15 points )The data type Point3D is comparable. Complete the parts about the comparators. import java.util. Comparator; // An immutable data type representing

 1 ,9 7.(15 points )The data type Point3D is comparable. Complete
the parts about the comparators. import java.util. Comparator; // An immutable data
type representing a 3D point. public class Point3D implements Comparable private final

1 ,9 7.(15 points )The data type Point3D is comparable. Complete the parts about the comparators. import java.util. Comparator; // An immutable data type representing a 3D point. public class Point3D implements Comparable private final double x; // x coordinate private final double y; // y coordinate private final double z; // z coordinate // Construct a point in 3D given its coordinates. public Point3D (double x, double y double z) { this.x = x; this.y = Y; // The Euclidean distance between this po public double distance (Point3D that) [ return Math.Bart - that . (x - Chat stance between this point and that hat.x) (x - that.x) + ly - that.y). y - that.y) + (z - that.z) ( - that.:)); 1 0 . Or 1 depending on this points Euclidean // distance to the origin (0, 0, 0) is less than 1 equal to, or greater than that point's Eucli // distance to the origin. public int compare to (Point3D that) Point3D origin = new Point3D(0, 0, 0); double a distance (origin); double b = that distance (origin); if (a xOrder t) { 7.a) private static class xorder implements Comparator yOrder() { 7.c) // Helper y-coordinate comparator. private static class Yorder implements Comparator 1/ -1, 0, or 1 depending on whether pi's y-coordinate // is less than, equal to, or greater than p2's // y-coordinate. public int compare (Point3D pi, Point3D p2) { I! A string representation of the point, as "(x, y, z)". publie String toString() {

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 Databases Questions!