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

public String whileLoop() {

int counter = 0;

String result = "";
while (counter < personArray.length) {
result += personArray[counter].toString();
counter++;

}

return result;


}

// 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

// end loop
return result;
}





public String forLoop() {

int i = 0;
String result = "";
for (i = 0; i < personArray.length; i++) {
result += personArray[i].toString();
}
return result;
// 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`
// append `stringRepresentation` to `result` variable
// end loop

return result;
}



public String forEachLoop() {
String result = "";


public String forEachLoop() {

// identify array's type
// identify array's variable-name

Expand All @@ -54,12 +74,25 @@ public String forEachLoop() {
// get `string Representation` of `currentPerson`
// append `stringRepresentation` to `result` variable
// end loop
String result = "";



for (Person i : personArray) {


result += i.toString();
}


return result;
}


public Person[] getPersonArray() {



return personArray;
}
}