Class DecimalConverter
Object
DecimalConverter
- All Implemented Interfaces:
Converter
This class converts DecimalCoordinate objects to DMSCoordinate objects.
This class should be constructed with a DecimalCoordinate object.
Once that object is set, convert() can be called to convert the decimalObj
to a DMSCoordinate object and set it appropriately.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) DMSCoordinateOnce convert() is called, this convertedObj is set to the correct DMSCoordinate.(package private) DecimalCoordinateThe DecimalCoordinate object to be converted. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor to assign decimalObj to 0.DecimalConverter(DecimalCoordinate decimalObj) Overloaded constructor which takes in a pre-existing DecimalCoordinate object and sets decimalObj equal to it. -
Method Summary
Modifier and TypeMethodDescriptionvoidconvert()Implements the convert() method from the Converter interface.Returns convertedObj.
-
Field Details
-
decimalObj
DecimalCoordinate decimalObjThe DecimalCoordinate object to be converted. -
convertedObj
DMSCoordinate convertedObjOnce convert() is called, this convertedObj is set to the correct DMSCoordinate.
-
-
Constructor Details
-
DecimalConverter
public DecimalConverter()Default constructor to assign decimalObj to 0. -
DecimalConverter
Overloaded constructor which takes in a pre-existing DecimalCoordinate object and sets decimalObj equal to it.- Parameters:
decimalObj-DecimalCoordinateobject with values already set.
-
-
Method Details
-
getConvertedObj
Returns convertedObj.- Returns:
-
convert
public void convert()Implements the convert() method from the Converter interface. Should take the decimalObj and convert that to a DMSCoordinate, once converted, set convertedObj to the new DecimalCoordinate. The Math.floor() function will come in handy! There is some more information in the Additional Info section of the README. Math.floor() also returns a double, so to convert from double to int use the `(int)` cast before a double to "cast" it to an int.When creating and setting the convertedObj, I would recommend to use the
DMSCoordinate(int, int, int, int, int, int)constructor. A helpful graphic of the formula in action is in the GitHub README, and a link to an explanation is available in the README.
-