public class GeoLocation {latitude private double latitude; private double longi
ID: 3539770 • Letter: P
Question
public class GeoLocation
{latitude
private double latitude;
private double longitude;
// Construct a GeoLocation given the latitude and longitude.
public GeoLocation(double latitude, double longitude)
{
// TBD
this.latitude = latitude;
this.longitud = longitud;
}
// Return the great circle distance between this location and b.
public double distanceTo(GeoLocation b)
{
// TBD
}
// Is this location the same as b?
public boolean equals(GeoLocation b)
{
// TBD
if((this.latitude == b.latitude) && (this.longitude == b.longitude)){
return false;
}
else
return true;
}
// Return a String representation of this location.
public String toString()
{
// TBD
return latitude + ", " + longitud;
}
// Test driver.
public static void main(String[] args)
{
GeoLocation a = new GeoLocation(48.87, -2.33);
GeoLocation b = new GeoLocation(37.8, 122.4);
GeoLocation c = new GeoLocation(37.8, 122.4);
System.out.println("Should print 48.87, -2.33: " + a);
System.out.println("Should print 5561.369177680733: " +
a.distanceTo(b));
System.out.println("Should print false: " + a.equals(b));
System.out.println("Should print true: " + b.equals(c));
}
}
I am writing this program but I don't know how to write " public double distanceTo(GeoLocation b)"
Explanation / Answer
public double distanceTo(GeoLocation b)
{
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.