Class DMSCoordinate

Object
DMSCoordinate

public class DMSCoordinate extends Object
Class which contains the Degrees, Minutes, and Seconds for each coordinate of DMS format For simplicity, we will not be including the cardinal direction associated with latitude and longitude.
  • Field Summary

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

    Constructors
    Constructor
    Description
    Default Constructor which initializes each value to 0.
    DMSCoordinate(int degreesLat, int minutesLat, int secondsLat, int degreesLong, int minutesLong, int secondsLong)
    Overloaded constructor, for the case that each degrees, minute, and second is seperate already.
    DMSCoordinate(String latAndLong)
    Overloaded constructor in the case that the Latitude and Longitude were not split before creating DMSCoordinate Object.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets Latitudinal Degrees value.
    int
    Gets Longitudinal Degrees value.
    Converts latitude DMS to a readable format
    Converts longitude DMS to a readable format
    int
    Gets Latitudinal Minutes value.
    int
    Gets Longitudinal Minutes value.
    int
    Gets Latitudinal Seconds value.
    int
    Gets Longitudinal Seconds value.
    void
    setLatitude(String latitude)
    Takes in a String and assigns the latitude class variables based upon their position in the String.
    void
    setLongitude(String longitude)
    Takes in a String and assigns the longitude class variables based upon their position in the String.
    Converts both latitude and longitude to their String formats and appends them to eachother with a space in between then returns full String.

    Methods inherited from class Object

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

    • degreesLat

      int degreesLat
    • minutesLat

      int minutesLat
    • secondsLat

      int secondsLat
    • degreesLong

      int degreesLong
    • minutesLong

      int minutesLong
    • secondsLong

      int secondsLong
  • Constructor Details

    • DMSCoordinate

      public DMSCoordinate()
      Default Constructor which initializes each value to 0.
    • DMSCoordinate

      public DMSCoordinate(String latAndLong)
      Overloaded constructor in the case that the Latitude and Longitude were not split before creating DMSCoordinate Object. The provided String must be split into a latitude and longitude String using substring(). After being split, each is sent to setLatitude(String) or setLongitude(String).
      Parameters:
      latAndLong - Both Latitude and Longitude, should be seperated by a space, "LATITUDE LONGITUDE"
    • DMSCoordinate

      public DMSCoordinate(int degreesLat, int minutesLat, int secondsLat, int degreesLong, int minutesLong, int secondsLong)
      Overloaded constructor, for the case that each degrees, minute, and second is seperate already.
  • Method Details

    • getDegreesLat

      public int getDegreesLat()
      Gets Latitudinal Degrees value.
      Returns:
      Degrees in Latitude
    • getMinutesLat

      public int getMinutesLat()
      Gets Latitudinal Minutes value.
      Returns:
      Minutes in Latitude
    • getSecondsLat

      public int getSecondsLat()
      Gets Latitudinal Seconds value.
      Returns:
      Seconds in Latitude
    • getDegreesLong

      public int getDegreesLong()
      Gets Longitudinal Degrees value.
      Returns:
      Degrees in Longitude
    • getMinutesLong

      public int getMinutesLong()
      Gets Longitudinal Minutes value.
      Returns:
      Minutes in Longitude
    • getSecondsLong

      public int getSecondsLong()
      Gets Longitudinal Seconds value.
      Returns:
      Seconds in Longitude
    • getLatitude

      public String getLatitude()
      Converts latitude DMS to a readable format
      Returns:
      String should follow the format ex. 38°53'12", DEGREES°MINUTES'SECONDS"
    • getLongitude

      public String getLongitude()
      Converts longitude DMS to a readable format
      Returns:
      String should follow the format 38°53'12", DEGREES°MINUTES'SECONDS"
    • setLatitude

      public void setLatitude(String latitude)
      Takes in a String and assigns the latitude class variables based upon their position in the String.

      After each number is parsed, they must all be checked to be in the range of 0 to 60. If any are not in this range of 0-60, all latitude values are set to 0, and a String is printed to indicate an error has occurred. Given they are in this range, each value is set accordingly.

      Parameters:
      latitude - - String in the format 38°53'12", DEGREES°MINUTES'SECONDS"
    • setLongitude

      public void setLongitude(String longitude)
      Takes in a String and assigns the longitude class variables based upon their position in the String.

      After each number is parsed, they must all be checked to be in the range of 0 to 60. If any are not in this range of 0-60, all longitude values are set to 0, and a String is printed to indicate an error has occurred. Given they are in this range, each value is set accordingly.

      Parameters:
      longitude - - String in the format 38°53'12"
    • toString

      public String toString()
      Converts both latitude and longitude to their String formats and appends them to eachother with a space in between then returns full String. ex: "LATITUDE LONGITUDE"
      Overrides:
      toString in class Object
      Returns:
      String containing both latitude and longitude.