From 3ad2b6aae4de82104f1dde0ed63344f95de6fd4e Mon Sep 17 00:00:00 2001 From: Fennel Kora Date: Fri, 12 Apr 2024 22:30:29 -0400 Subject: [PATCH] added constructor, validateAddress, setCoordsForAddress, and setDestinationAddress --- Destination.java | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/Destination.java b/Destination.java index d27684b..0329798 100644 --- a/Destination.java +++ b/Destination.java @@ -1,16 +1,32 @@ public class Destination { - private String address; - private class coordinates { - private float longitude; - private float latitude; + private String destinationAddress; + private double[] coordinates; //stores lat/long as terms in the array - private float getLongitude() {return longitude;} - private float getLatitude() {return latitude;} - public void setLongitude(float coord) {longitude = coord;} - public void setLatitude(float coord) {latitude = coord;} - public float[] getCoordinates() { - float[] coordsArray = {getLatitude(), getLongitude()}; - return coordsArray; + 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 + //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 } } } \ No newline at end of file