Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class GIS {
- /**
- *This is the main method for the Class.
- *It is called by the interpreter to determine how to run the program.
- **/
- public static void main (String args[]) {
- /**
- *This is the point where we are.
- **/
- Point weAreHerePoint = new Point ();
- /**
- *These are the setup points for where we are.
- **/
- weAreHerePoint.setX (200.0);
- weAreHerePoint.setY (300.0);
- weAreHerePoint.setZ (50.0);
- weAreHerePoint.setAttribute ("River deep");
- /**
- *This is the point where the destination is located.
- **/
- Point destinationPoint = new Point ();
- /**
- *These are the setup points for where the destination is located.
- **/
- destinationPoint.setX (400.0);
- destinationPoint.setY (500.0);
- destinationPoint.setZ (1500.0);
- destinationPoint.setAttribute ("Mountain high");
- /**
- *This makes an object of the GIS class
- **/
- GIS gis = new GIS();
- double result =
- gis.getDistanceBetween(weAreHerePoint, destinationPoint);
- /**
- *This prints the difference between the two locations in the Y direction.
- **/
- System.out.println(gis.getDistanceBetween(weAreHerePoint,destinationPoint));
- }
- /**
- *This calculates the distance in the Y direction inside the 'getDistanceBetween' method.
- **/
- double getDistanceBetween(Point p1, Point p2) {
- double x1;
- double x2;
- double y1;
- double y2;
- double z1;
- double z2;
- x1 = p1.getX();
- x2 = p2.getX();
- y1 = p1.getY();
- y2 = p2.getY();
- z1 = p1.getZ();
- z2 = p2.getZ();
- double distance = Math.sqrt((x1-x2) + (y1-y2) + (z1-z2));
- return distance;
- }
- }
Add Comment
Please, Sign In to add comment