diff --git a/src/main/java/com/zipcodewilmington/PersonHandler.java b/src/main/java/com/zipcodewilmington/PersonHandler.java index 63d9fe6..61b4c24 100644 --- a/src/main/java/com/zipcodewilmington/PersonHandler.java +++ b/src/main/java/com/zipcodewilmington/PersonHandler.java @@ -11,9 +11,17 @@ public PersonHandler(Person[] personArray) { } public String whileLoop() { + String result = ""; - // assume there is a `counter` - // while `counter` is less than length of array + + int counter = 0; // assume there is a `counter` + + while ( counter < personArray.length ) { + // while `counter` is less than length of array + + result += personArray[counter].toString(); + counter++; + } // begin loop // use `counter` to identify the `current Person` in the array @@ -21,6 +29,8 @@ public String whileLoop() { // append `stringRepresentation` to `result` variable // end loop + + return result; } @@ -32,6 +42,9 @@ public String forLoop() { // identify terminal condition // identify increment + for ( int i = 0; i < personArray.length; i++ ) { + result += personArray[i].toString(); + } // use the above clauses to declare for-loop signature // begin loop // use `counter` to identify the `current Person` in the array @@ -49,6 +62,12 @@ public String forEachLoop() { // identify array's type // identify array's variable-name + for ( Person person : personArray ) { + + result += person.toString(); + + } + // use the above discoveries to declare for-each-loop signature // begin loop // get `string Representation` of `currentPerson`