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
31 changes: 25 additions & 6 deletions src/main/java/com/zipcodewilmington/PersonHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,27 @@ public PersonHandler(Person[] personArray) {
}

public String whileLoop() {
String result = "";
//String result = "";
// create a `counter`
// while `counter` is less than length of array
// begin loop
int counter=0;

StringBuilder sbForArray = new StringBuilder();

while(counter< personArray.length){
//
sbForArray.append(personArray[counter]);
counter++;
//array.append(System.lineSeparator());
}

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

// end loop
return result;
return sbForArray.toString();
}


Expand All @@ -31,15 +41,19 @@ public String forLoop() {
// identify initial value
// identify terminal condition
// identify increment

//int counter=0;
StringBuilder array = new StringBuilder();
for(int counter=0;counter< personArray.length;counter++)
{
array.append(personArray[counter]);
}
return array.toString();
// 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
// end loop

return result;
}


Expand All @@ -49,13 +63,18 @@ public String forEachLoop() {
// identify array's type
// identify array's variable-name

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

return result;
}


Expand Down