Guest User

Untitled

a guest
May 23rd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. public class GIS {
  2.  
  3.  
  4. /**
  5. *This is the main method for the Class.
  6. *It is called by the interpreter to determine how to run the program.
  7. **/
  8. public static void main (String args[]) {
  9.  
  10.  
  11. /**
  12. *This is the point where we are.
  13. **/
  14. Point weAreHerePoint = new Point ();
  15.  
  16.  
  17. /**
  18. *These are the setup points for where we are.
  19. **/
  20. weAreHerePoint.setX (200.0);
  21. weAreHerePoint.setY (300.0);
  22. weAreHerePoint.setZ (50.0);
  23. weAreHerePoint.setAttribute ("River deep");
  24.  
  25.  
  26. /**
  27. *This is the point where the destination is located.
  28. **/
  29. Point destinationPoint = new Point ();
  30.  
  31.  
  32. /**
  33. *These are the setup points for where the destination is located.
  34. **/
  35. destinationPoint.setX (400.0);
  36. destinationPoint.setY (500.0);
  37. destinationPoint.setZ (1500.0);
  38. destinationPoint.setAttribute ("Mountain high");
  39.  
  40.  
  41. /**
  42. *This makes an object of the GIS class
  43. **/
  44. GIS gis = new GIS();
  45.  
  46. double result =
  47.  
  48. gis.getDistanceBetween(weAreHerePoint, destinationPoint);
  49.  
  50.  
  51. /**
  52. *This prints the difference between the two locations in the Y direction.
  53. **/
  54. System.out.println(gis.getDistanceBetween(weAreHerePoint,destinationPoint));
  55. }
  56.  
  57.  
  58.  
  59. /**
  60. *This calculates the distance in the Y direction inside the 'getDistanceBetween' method.
  61. **/
  62.  
  63. double getDistanceBetween(Point p1, Point p2) {
  64.  
  65. double x1;
  66. double x2;
  67. double y1;
  68. double y2;
  69. double z1;
  70. double z2;
  71.  
  72. x1 = p1.getX();
  73. x2 = p2.getX();
  74. y1 = p1.getY();
  75. y2 = p2.getY();
  76. z1 = p1.getZ();
  77. z2 = p2.getZ();
  78.  
  79. double distance = Math.sqrt((x1-x2) + (y1-y2) + (z1-z2));
  80.  
  81. return distance;
  82.  
  83. }
  84. }
Add Comment
Please, Sign In to add comment