From 7467ebe3080e9bcf3ca4e36a89cc95423f4c8f83 Mon Sep 17 00:00:00 2001 From: Quatrani Paul Date: Tue, 2 Nov 2021 19:53:37 -0400 Subject: [PATCH 1/2] completed while loop --- .../java/com/zipcodewilmington/PersonHandler.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/zipcodewilmington/PersonHandler.java b/src/main/java/com/zipcodewilmington/PersonHandler.java index 6970947..f8d0fb9 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; } From 0add8faab51f46edfb583163fea350d610b379ef Mon Sep 17 00:00:00 2001 From: Quatrani Paul Date: Tue, 2 Nov 2021 20:12:50 -0400 Subject: [PATCH 2/2] completed all methods --- src/main/java/com/zipcodewilmington/PersonHandler.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/zipcodewilmington/PersonHandler.java b/src/main/java/com/zipcodewilmington/PersonHandler.java index f8d0fb9..e814153 100644 --- a/src/main/java/com/zipcodewilmington/PersonHandler.java +++ b/src/main/java/com/zipcodewilmington/PersonHandler.java @@ -15,7 +15,7 @@ public String whileLoop() { // create a `counter` int counter = 0; // while `counter` is less than length of array - while (counter < this.personArray.length) { + while (counter< this.personArray.length) { // begin loop // use `counter` to identify the `current Person` in the array // get `string Representation` of `currentPerson` @@ -33,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 @@ -52,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