Class DecimalCoordinate

Object
DecimalCoordinate

public class DecimalCoordinate extends Object
Class which contains the Latitude and Longitude for a DecimalCoordinate object. For simplicity, we will not be including the cardinal direction associated with the latitude and longitude.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) double
     
    (package private) double
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default 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.
    Overloaded constructor in the case that the latitude and longitude were provided in the same String.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Gets latitude value.
    double
    Gets longitude value.
    void
    setLatitude(double latitude)
    Sets latitude value.
    void
    setLongitude(double longitude)
    Sets longitude value.
    Creates a String with both the Latitude and Longitude, seperated by a space.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • latitude

      double latitude
    • longitude

      double longitude
  • Constructor Details

    • DecimalCoordinate

      public DecimalCoordinate()
      Default constructor which initializes each variable to 0.
    • DecimalCoordinate

      public DecimalCoordinate(String latAndLong)
      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

      public String toString()
      Creates a String with both the Latitude and Longitude, seperated by a space. and returns. ex: "38.6578 12.5467"
      Overrides:
      toString in class Object