35 lines
No EOL
1.4 KiB
Java
35 lines
No EOL
1.4 KiB
Java
public class Destination {
|
|
private String destinationAddress;
|
|
private double[] coordinates; //stores lat/long as terms in the array
|
|
|
|
public Destination(String inputAddress) { //constructor takes address, validates, then retrieves GPS coordinates and stores them
|
|
setDestinationAddress(inputAddress);
|
|
}
|
|
|
|
private boolean validateAddress() { //determines if provided address is valid
|
|
//execute call to address verification service API
|
|
//for the purposes of control flow in this example, will always return true
|
|
return true;
|
|
}
|
|
|
|
private void setCoordsForAddress() {
|
|
//execute call using address out to covnersion API such as Google Geocoding code example
|
|
//a helper function has been written to return a set of coordinates for testing in lieu of api connection
|
|
HelperFunctions apiConnection = new HelperFunctions();
|
|
double[] tmpCoords = apiConnection.geocodingAPI(destinationAddress);
|
|
coordinates[0] = tmpCoords[0];
|
|
coordinates[1] = tmpCoords[1];
|
|
}
|
|
|
|
public void setDestinationAddress(String newAddress) {
|
|
if (validateAddress()) {
|
|
destinationAddress = newAddress;
|
|
setCoordsForAddress();
|
|
} else {
|
|
//prompt error message
|
|
}
|
|
}
|
|
|
|
public double[] getDestinationCoordinates() {return coordinates;}
|
|
public String getDestinationAddress() {return destinationAddress;}
|
|
} |