From ca4ba4b44a94f959e3c0a4c9a70bae55292d50a0 Mon Sep 17 00:00:00 2001 From: Keerthana Srinivasan Date: Wed, 3 Nov 2021 16:52:15 -0400 Subject: [PATCH] completed lab --- .../com/zipcodewilmington/PersonHandler.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/zipcodewilmington/PersonHandler.java b/src/main/java/com/zipcodewilmington/PersonHandler.java index 6970947..5db9288 100644 --- a/src/main/java/com/zipcodewilmington/PersonHandler.java +++ b/src/main/java/com/zipcodewilmington/PersonHandler.java @@ -7,6 +7,7 @@ public class PersonHandler { private final Person[] personArray; public PersonHandler(Person[] personArray) { + this.personArray = personArray; } @@ -15,6 +16,14 @@ public String whileLoop() { // create a `counter` // while `counter` is less than length of array // begin loop + int count = 0; + while(count < personArray.length) + { + result = result.concat(personArray[count].toString()); + count ++; + + } + // use `counter` to identify the `current Person` in the array // get `string Representation` of `currentPerson` @@ -31,7 +40,9 @@ public String forLoop() { // identify initial value // identify terminal condition // identify increment - + for(int i = 0; i < personArray.length; i++){ + result = result .concat(personArray[i].toString()); + } // use the above clauses to declare for-loop signature // begin loop // use `counter` to identify the `current Person` in the array @@ -48,7 +59,9 @@ public String forEachLoop() { String result = ""; // identify array's type // identify array's variable-name - + for(Person person : personArray){ + result = result .concat(person.toString()) ; + } // use the above discoveries to declare for-each-loop signature // begin loop // get `string Representation` of `currentPerson`