Class DecimalCoordinate
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor which initializes each variable to 0.DecimalCoordinate(double latitude, double longitude) Overloaded constructor, where the parameters are a String form of latitude and longitude.DecimalCoordinate(String latAndLong) Overloaded constructor in the case that the latitude and longitude were provided in the same String. -
Method Summary
Modifier and TypeMethodDescriptiondoubleGets latitude value.doubleGets longitude value.voidsetLatitude(double latitude) Sets latitude value.voidsetLongitude(double longitude) Sets longitude value.toString()Creates a String with both the Latitude and Longitude, seperated by a space.
-
Field Details
-
latitude
double latitude -
longitude
double longitude
-
-
Constructor Details
-
DecimalCoordinate
public DecimalCoordinate()Default constructor which initializes each variable to 0. -
DecimalCoordinate
Overloaded constructor in the case that the latitude and longitude were provided in the same String.After the latitude and longitude are parsed, a check must be made to view if the Latitude is in the range of 0 to 60, and the Longitude in the range of 0 to 60. If both are in these ranges, the values can be set. If one of these values is not in their respective ranges, both values are to be set to 0, and a String should be printed to indicate user error.
Typically latitudes range between -90 to 90 and longitudes between -180 to 180. For our purposes and since we are not including the cardinal direction, these ranges have been changed to 0-60.
- Parameters:
latAndLong- Both latitude and longitude. Should be seperated by a space. ex: 38.6578 12.5467
-
DecimalCoordinate
public DecimalCoordinate(double latitude, double longitude) Overloaded constructor, where the parameters are a String form of latitude and longitude. Sets the latitude and longitude given to the class variables.- Parameters:
latitude- Will be given as doubles in the format, ex: "38.5465"longitude- Will be given in the format, ex: "38.5465"
-
-
Method Details
-
getLatitude
public double getLatitude()Gets latitude value.- Returns:
- Latitude class variable.
-
getLongitude
public double getLongitude()Gets longitude value.- Returns:
- Longitude class variable.
-
setLatitude
public void setLatitude(double latitude) Sets latitude value.The double provided must be checked to be in the range of 0 to 60, if it is not, print an error message and set the latitude to 0.
- Parameters:
latitude- Provided as a double.
-
setLongitude
public void setLongitude(double longitude) Sets longitude value.The double provided must be checked to be in the range of 0 to 60, if it is not, print an error message and set the longitude to 0.
- Parameters:
longitude- Provided as a double.
-
toString
Creates a String with both the Latitude and Longitude, seperated by a space. and returns. ex: "38.6578 12.5467"
-