Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions src/main/java/com/zipcodewilmington/PersonHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ public PersonHandler(Person[] personArray) {
public String whileLoop() {
String result = "";
// create a `counter`
int counter = 0;
// 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

while (counter < personArray.length) {
// use `counter` to identify the `current Person` in the array
// get `string Representation` of `currentPerson`
String currentPerson = String.format("%s", personArray[counter]);
// append `stringRepresentation` to `result` variable
result += currentPerson;
// end loop
counter += 1;
}
return result;
}

Expand All @@ -31,14 +35,16 @@ public String forLoop() {
// identify initial value
// identify terminal condition
// identify increment

// use the above clauses to declare for-loop signature
// begin loop
// use `counter` to identify the `current Person` in the array
// get `string Representation` of `currentPerson`
for (int i = 0; i < personArray.length; i++) {
// use `counter` to identify the `current Person` in the array
// get `string Representation` of `currentPerson`
String currentPerson = String.format("%s",personArray[i]);
// append `stringRepresentation` to `result` variable
result += currentPerson;
// end loop

}
return result;
}

Expand All @@ -48,11 +54,13 @@ public String forEachLoop() {
String result = "";
// identify array's type
// identify array's variable-name

// use the above discoveries to declare for-each-loop signature
// begin loop
// get `string Representation` of `currentPerson`
// append `stringRepresentation` to `result` variable
for (Person currentPerson : personArray) {
// get `string Representation` of `currentPerson`
// append `stringRepresentation` to `result` variable
result += String.format("%s", currentPerson);
}
// end loop

return result;
Expand Down