diff --git a/src/main/java/com/zipcodewilmington/PersonHandler.java b/src/main/java/com/zipcodewilmington/PersonHandler.java index 6970947..e814153 100644 --- a/src/main/java/com/zipcodewilmington/PersonHandler.java +++ b/src/main/java/com/zipcodewilmington/PersonHandler.java @@ -13,14 +13,16 @@ public PersonHandler(Person[] personArray) { public String whileLoop() { String result = ""; // create a `counter` + int counter = 0; // while `counter` is less than length of array + while (counter< this.personArray.length) { // begin loop - - // use `counter` to identify the `current Person` in the array - // get `string Representation` of `currentPerson` - // append `stringRepresentation` to `result` variable - + // use `counter` to identify the `current Person` in the array + // get `string Representation` of `currentPerson` + // append `stringRepresentation` to `result` variable + result = result + this.personArray[counter++].toString(); // end loop + } return result; } @@ -31,7 +33,9 @@ public String forLoop() { // identify initial value // identify terminal condition // identify increment - + for(int counter = 0; counter < this.personArray.length; counter++){ + result = result + this.personArray[counter].toString(); + } // use the above clauses to declare for-loop signature // begin loop // use `counter` to identify the `current Person` in the array @@ -50,6 +54,9 @@ public String forEachLoop() { // identify array's variable-name // use the above discoveries to declare for-each-loop signature + for( Person person: this.personArray){ + result = result + person.toString(); + } // begin loop // get `string Representation` of `currentPerson` // append `stringRepresentation` to `result` variable