Question: Lab Exercise 06.2 Coordinate Geometry USE JAVA The purpose of this exercise is to demonstrate class reusability by creating a class that is useful in
Lab Exercise 06.2
Coordinate Geometry
USE JAVA
The purpose of this exercise is to demonstrate class reusability by creating a class that is useful in a variety of contexts. You will design and code a class named Point which can represent a geometric point with x- , y- and z-coordinates.
The class will contain
A private, class-level variable, a String, which will be the points ID.
Three private, class-level integer variables x, y and z that represent the coordinates of the point.
A no-argument (default) constructor that initializes x, y and z with 0 values.
A constructor that accepts three arguments and initializes x, y and z with those values.
A getX( ) method, a getY( ) method and a getZ() method.
A getID( ) method
A method named distance that returns the distance from this point to another point.
public int distance( point p);
I have written a main to test your class. This main method will test the point class and all of its methods by generating an ArrayList of 8 points (at x, y and z values -15 to +15).
The test program will supply pairs of points by using two String values, (ID names for two points). The program will then display the distance between the two specified points. This will be done for a number of point-pairs.
Testing
Files:
Main.java supplied by blackboard
Point.java supplied by you
Main.java
import java.util.ArrayList; import javax.swing.JOptionPane; public class Main { private static final int N_POINTS = 13; private static final int N_DISTANCES = 7; private static final int N_USER_PICKS = 3; private static ArrayList geog = new ArrayList<>(); public static void main(String[]args) { Point p; String name; System.out.println(" populate the list of points "); for (int i=0; i Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
