Copy your Tuple
and Pair
classes from /csci102/labs/apr6 into csci102/hw/apr7.
Write a class named Point3D
that models a point in 3D space. The class should extend Tuple and implement the Comparable
interface.
-
- The
compareTo
method should return 1 if the distance between the instance on which compareTo is called and (0,0,0) is larger than the distance between the instance passed into the method and (0,0,0). - The
compareTo
method should return -1 if the distance between the instance on which compareTo is called and (0,0,0) is smaller than the distance between the instance passed into the method and (0,0,0). - The
compareTo
method should return 0 if the distance between the instance on which compareTo is called and (0,0,0) is equal to the distance between the instance passed into the method and (0,0,0).
- The
Write a class named Driver
that creates multiple instances of Point3D
and tests the methods in the Point3D
and Tuple
classes.
© 2021, Eric. All rights reserved.