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
23 changes: 21 additions & 2 deletions src/main/java/com/zipcodewilmington/PersonHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,26 @@ 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
// get `string Representation` of `currentPerson`
// append `stringRepresentation` to `result` variable

// end loop


return result;
}

Expand All @@ -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
Expand All @@ -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`
Expand Down