added constructor, validateAddress, setCoordsForAddress, and setDestinationAddress

This commit is contained in:
Fennel Kora 2024-04-12 22:30:29 -04:00
parent 35438c703a
commit 3ad2b6aae4

View file

@ -1,16 +1,32 @@
public class Destination { public class Destination {
private String address; private String destinationAddress;
private class coordinates { private double[] coordinates; //stores lat/long as terms in the array
private float longitude;
private float latitude;
private float getLongitude() {return longitude;} public Destination(String inputAddress) { //constructor takes address, validates, then retrieves GPS coordinates and stores them
private float getLatitude() {return latitude;} setDestinationAddress(inputAddress);
public void setLongitude(float coord) {longitude = coord;} }
public void setLatitude(float coord) {latitude = coord;}
public float[] getCoordinates() { private boolean validateAddress() { //determines if provided address is valid
float[] coordsArray = {getLatitude(), getLongitude()}; //execute call to address verification service API
return coordsArray; //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
//tmpCoords = geocodingAPI(address); with the assumption an array of coordinates is returned
//these explicit declarations will serve as testing values
double[] tmpCoords = { 27.993718340483223, -80.63008635738797};
coordinates[0] = tmpCoords[0];
coordinates[1] = tmpCoords[1];
}
public void setDestinationAddress(String newAddress) {
if (validateAddress()) {
destinationAddress = newAddress;
setCoordsForAddress();
} else {
//prompt error message
} }
} }
} }