Skip to content

Passed all tests #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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: 23 additions & 15 deletions src/main/java/com/zipcodewilmington/PersonHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ 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 < personArray.length) {
// begin loop

// use `counter` to identify the `current Person` in the array
// get `string Representation` of `currentPerson`
// append `stringRepresentation` to `result` variable

String currentPerson = personArray[counter].toString();
result += currentPerson;
counter++;
// 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 @@ -31,14 +35,16 @@ public String forLoop() {
// identify initial value
// identify terminal condition
// identify increment

// use the above clauses to declare for-loop signature
for(int i = 0; i < personArray.length; i++) {
// 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`
// append `stringRepresentation` to `result` variable
// use `counter` to identify the `current Person` in the array
String stringRepresentation = personArray[i].toString();
// get `string Representation` of `currentPerson`
// append `stringRepresentation` to `result` variable
// end loop

result += stringRepresentation;
}
return result;
}

Expand All @@ -49,12 +55,14 @@ public String forEachLoop() {
// identify array's type
// identify array's variable-name

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

}
return result;
}

Expand Down