diff --git a/src/main/java/com/zipcodewilmington/PersonHandler.java b/src/main/java/com/zipcodewilmington/PersonHandler.java index 6970947..c34e647 100644 --- a/src/main/java/com/zipcodewilmington/PersonHandler.java +++ b/src/main/java/com/zipcodewilmington/PersonHandler.java @@ -15,11 +15,17 @@ public String whileLoop() { // create a `counter` // while `counter` is less than length of array // begin loop - - // use `counter` to identify the `current Person` in the array - // get `string Representation` of `currentPerson` - // append `stringRepresentation` to `result` variable - + int i = 0; + while (i< personArray.length) { + // use `counter` to identify the `current Person` in the array + personArray[i].getFirstName(); + personArray[i].getLastName(); + // get `string Representation` of `currentPerson` + String addName = personArray[i].toString(); + // append `stringRepresentation` to `result` variable + result += addName; + i++; + } // end loop return result; } @@ -29,11 +35,21 @@ public String whileLoop() { public String forLoop() { String result = ""; // identify initial value + int initial = 0; // identify terminal condition + int terminal = personArray.length; // identify increment + //i++ // use the above clauses to declare for-loop signature // begin loop + for (int i = initial; i < terminal ; i++) { + personArray[i].getFirstName(); + personArray[i].getLastName(); + String addName = personArray[i].toString(); + result += addName; + + } // use `counter` to identify the `current Person` in the array // get `string Representation` of `currentPerson` // append `stringRepresentation` to `result` variable @@ -51,10 +67,16 @@ public String forEachLoop() { // use the above discoveries to declare for-each-loop signature // begin loop - // get `string Representation` of `currentPerson` - // append `stringRepresentation` to `result` variable + for (Person peeps: personArray ) { + peeps.getFirstName(); + peeps.getLastName(); + String addName = peeps.toString(); + result += addName; + + // get `string Representation` of `currentPerson` + // append `stringRepresentation` to `result` variable // end loop - + } return result; }