Package geo
Class Angle
- java.lang.Object
-
- geo.Angle
-
public class Angle extends Object
Immutable datatype representing an angle in a geographic coordinate system, measured in degrees, minutes (1/60ths of a degree), and seconds (1/60ths of a minute). Angles can be used for many purposes, but for some uses, only certain angles are valid:- Valid angles for latitude range from 0 to 90 deg N or S, inclusive. Note that 0 deg N & S are different representations of the same latitude (equator).
- Valid angles for longitude range from 0 to 180 deg E or W, inclusive. 0 deg E & W are different representations of the same longitude (prime meridian), and 180 deg E & W are also different representations of the same longitude (antimeridian).
- Valid angles for displacement range from 0 to 180 deg, inclusive.
PS1 instructions: do NOT change this class.
-
-
Constructor Summary
Constructors Constructor Description Angle(int degrees, int minutes, int seconds, CardinalDirection direction)
Make a new angle of degrees degrees plus minutes arc minutes plus seconds arc seconds.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
degrees()
CardinalDirection
direction()
boolean
equals(Object obj)
int
hashCode()
int
minutes()
int
seconds()
String
toString()
-
-
-
Constructor Detail
-
Angle
public Angle(int degrees, int minutes, int seconds, CardinalDirection direction)
Make a new angle of degrees degrees plus minutes arc minutes plus seconds arc seconds. Must be at mostInteger.MAX_VALUE
degrees total.- Parameters:
degrees
- degrees of arc, must be nonnegativeminutes
- minutes of arc, must be nonnegativeseconds
- seconds of arc, must be nonnegativedirection
- cardinal direction of the angle
-
-
Method Detail
-
degrees
public int degrees()
- Returns:
- degrees of arc in this angle, must be nonnegative
-
minutes
public int minutes()
- Returns:
- arc minutes in this angle after accounting for whole degrees, must be in [0,60)
-
seconds
public int seconds()
- Returns:
- arc seconds in this angle after accounting for whole degrees and minutes, must be in [0, 60)
-
direction
public CardinalDirection direction()
- Returns:
- cardinal direction of this angle
-
-