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
38 changes: 30 additions & 8 deletions src/main/java/com/zipcodewilmington/PersonHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@ public String whileLoop() {
// create a `counter`
// 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

int i = 0;
while (i< personArray.length) {
// use `counter` to identify the `current Person` in the array
personArray[i].getFirstName();
personArray[i].getLastName();
// get `string Representation` of `currentPerson`
String addName = personArray[i].toString();
// append `stringRepresentation` to `result` variable
result += addName;
i++;
}
// end loop
return result;
}
Expand All @@ -29,11 +35,21 @@ public String whileLoop() {
public String forLoop() {
String result = "";
// identify initial value
int initial = 0;
// identify terminal condition
int terminal = personArray.length;
// identify increment
//i++

// use the above clauses to declare for-loop signature
// begin loop
for (int i = initial; i < terminal ; i++) {
personArray[i].getFirstName();
personArray[i].getLastName();
String addName = personArray[i].toString();
result += addName;

}
// use `counter` to identify the `current Person` in the array
// get `string Representation` of `currentPerson`
// append `stringRepresentation` to `result` variable
Expand All @@ -51,10 +67,16 @@ public String forEachLoop() {

// use the above discoveries to declare for-each-loop signature
// begin loop
// get `string Representation` of `currentPerson`
// append `stringRepresentation` to `result` variable
for (Person peeps: personArray ) {
peeps.getFirstName();
peeps.getLastName();
String addName = peeps.toString();
result += addName;

// get `string Representation` of `currentPerson`
// append `stringRepresentation` to `result` variable
// end loop

}
return result;
}

Expand Down