|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectGeographicCoordinates
public class GeographicCoordinates
The GeographicCoordinates class can be used to store and manipulate latitude
and longitude data for geographical operations. Latitude and logitude are
denoted by degrees and minutes to represent the North/South and East/West
coordinates respectively of a geographic location on the surface of the
earth. This class is to be used for HW4. For a complete description,
of this assignment go to:
http://www.cs.stonybrook.edu/~cse114/hw/HW4.html
This class only performs very basic functions, allowing the altering and
retrieving of integer variables that represent the degrees and minutes of
a distance measurement for the surface of the earth, as well as a character
variable that represents the direction of that measurement. In addition,
a simple toString method is provided to get a String representation of this
object in a neat form. Finally, some useful constants are provided for
possible Latitudinal/Longitudinal calculations.
Author:
Richard T. McKenna
Instructor
CSE 114 - Computer Science I - Fall 2009
Stony Brook University
Field Summary | |
---|---|
static int |
DEGREES_MIN
The int constant representing the minimum possible value for degrees as used in latitude and longitude representations. |
static int |
EARTH_RADIUS
The int constant representing the radius of the earth in miles. |
static int |
LAT_DEGREES_MAX
The int constant representing the maximum possible value for degrees as used in latitude representations. |
static int |
LONG_DEGREES_MAX
The int constant representing the maximum possible value for degrees as used in longitude representations. |
static int |
MINUTES_MAX
The int constant representing the maximum possible value for minutes as used in latitude and longitude representations. |
static int |
MINUTES_MIN
The int constant representing the minimum possible value for minutes as used in latitude and longitude representations. |
static double |
PI
The double constant representing the ratio of the circumference to the diameter of a circle. |
static double |
RADIAN_FACTOR
The double constant used to convert numbers from degrees to radians. |
Constructor Summary | |
---|---|
GeographicCoordinates()
Default Constructor for GeographicCoordinates, when called it initializes the degrees and minutes to 0, and the direction to '?'. Preconditions: The GeographicCoordinates() constructor is called by a program and the result is assigned either to a variable of type GeographicCoordinates or is passed to another method as a parameter of type GeographicCoordinates. Postconditions: A DistanceMeasurment object is constructed and memory is reserved for use for that object. |
|
GeographicCoordinates(int initDegrees,
int initMinutes,
char initDirection)
Second Constructor for GeographicCoordinates, when called it initializes the degrees, minutes, and direction instance variables to the values provided in the parameter list. Preconditions: This constructor is called by a program and the result is assigned either to a variable of type GeographicCoordinates or is passed to another method as a parameter of type GeographicCoordinates. Postconditions: A GeographicCoordinates object is constructed and memory is reserved for use for that object. |
Method Summary | |
---|---|
int |
getDegrees()
Accessor method that returns the degrees. Preconditions: this GeographicCoordinates object must be constructed with instance variables properly initialized. Postconditions: The degrees instance variable is returned. |
char |
getDirection()
Accessor method that returns the direction. Preconditions: this GeographicCoordinates object must be constructed with instance variables properly initialized. Postconditions: The direction instance variable is returned. |
int |
getMinutes()
Accessor method that returns the minutes. Preconditions: this GeographicCoordinates object must be constructed with instance variables properly initialized. Postconditions: The minutes instance variable is returned. |
void |
setDegrees(int changeDegrees)
Mutator method that allows the programmer to change the degrees. Preconditions: this GeographicCoordinates object must be constructed. Postconditions: The degrees instance variable is assigned the value of changeDegrees. |
void |
setDirection(char changeDirection)
Mutator method that allows the programmer to change the direction. Preconditions: this GeographicCoordinates object must be constructed. Postconditions: The direction instance variable is assigned the value of changeDirection. |
void |
setMinutes(int changeMinutes)
Mutator method that allows the programmer to change the minutes. Preconditions: this GeographicCoordinates object must be constructed. Postconditions: The minutes instance variable is assigned the value of changeMinutes. |
java.lang.String |
toString()
Method that returns a string that "textually represents" this object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int EARTH_RADIUS
public static final double PI
public static final double RADIAN_FACTOR
public static final int MINUTES_MIN
public static final int MINUTES_MAX
public static final int DEGREES_MIN
public static final int LAT_DEGREES_MAX
public static final int LONG_DEGREES_MAX
Constructor Detail |
---|
public GeographicCoordinates()
public GeographicCoordinates(int initDegrees, int initMinutes, char initDirection)
initDegrees
- Used to initialize the degrees of the specified GeographicCoordinatesinitMinutes
- Used to initialize the minutes of the specified GeographicCoordinatesinitDirection
- Used to initialize the direction of the specified GeographicCoordinatesMethod Detail |
---|
public int getDegrees()
public int getMinutes()
public char getDirection()
public void setDegrees(int changeDegrees)
changeDegrees
- the value to which the degrees value will be
changed for the specified GeographicCoordinatespublic void setMinutes(int changeMinutes)
changeMinutes
- the value to which the minutes value will be
changed for the specified GeographicCoordinates object.public void setDirection(char changeDirection)
changeDirection
- the value to which the direction value will be
changed for the specified GeographicCoordinates object.public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |