Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 2 (20 marks) Write a class named GeoCoordinate that retains the longitu

ID: 3693545 • Letter: Q

Question

Question 2 (20 marks) Write a class named GeoCoordinate that retains the longitude and latitude of an object on earth. Both longi- tude and latitude are represented as double values that must be in the range [-90.0,90.0]. The class has the following constructors: . GeoCoordinate0, which initializes the latitude to 0.0 (the equator), the longitude to 0.0 (the prime meridian) GeoCoordinate(double longitude, double latitude): initializes the longitude and latitudes to values in [-90.0,90.0] The class has the following methods double getLongitude0 and double getLatitude0. that return the longitude and latitude of the GeoCo- ordinate boolean equals(GeoCoordinate g) that returns true if the GeoCoordinate of g and the current object represent the same GeoCoordinate, and false otherwise. boolean isWithinBounds(GeoCoordinate sw, GeoCoordinate ne) that takes exactly two GeoCoor dinates representing the south-west and north-est vertices of a rectangular area (see Figure below), and returns true if the current coordinate is within the bounds of the area, and false otherwise. (This can be used to check whether a given vehicle for example has gone outside of a certain geographic area) ne

Explanation / Answer

GeoCoordinate class:

public class GeoCoordinate{
   double latitude;
   double longiude;
   public GeoCoordinate(){
       latitude=0.0;
       longiude=0.0;
   }
   public GeoCoordinate(double latitude,double longiude){
       this.latitude=latitude;
       this.longiude=longiude;
   }
   public boolean equals(GeoCoordinate g){
       if(this.latitude==g.latitude && this.longiude==g.longiude){
           return true;
       }
       else{
           return false;
       }
   }
   public boolean isWithinBounds(GeoCoordinate sw,GeoCoordinate ne){
       if(this.latitude<ne.latitude && this.latitude>sw.latitude && this.longiude<ne.longiude && this.longiude>sw.longiude){
           return true;
       }
       return false;
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote