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
83 changes: 52 additions & 31 deletions src/main/java/com/zipcodewilmington/PersonHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,53 +13,74 @@ public PersonHandler(Person[] personArray) {
public String whileLoop() {
String result = "";
// create a `counter`
int counter = 0;
// 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

while (counter < this.personArray.length) { // begin loop
Person currentPerson = this.personArray[counter]; // use `counter` to identify the `current Person` in the array
String stringRepresentation = currentPerson.toString(); // get `string Representation` of `currentPerson`
result += stringRepresentation; // append `stringRepresentation` to `result` variable
counter++;
// end loop
}
return result;
}
/*
while (counter < personArray.length) {
String currentPerson = personArray[counter].toString();
result += currentPerson;
counter++;
}
return result;
}
*/

public String forLoop () {
String result = "";
// identify initial value
// identify terminal condition
// identify increment


public String forLoop() {
String result = "";
// identify initial value
// identify terminal condition
// identify increment

// use the above clauses to declare for-loop signature
// 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
//for (int i = 0; i < personArray.length; i++) {

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

return result;
}

for (int i = 0; i < personArray.length; i++) {
Person personNow = personArray[i];
result += personNow.toString();
}
return result;
}


public String forEachLoop() {
String result = "";
// identify array's type
// identify array's variable-name
public String forEachLoop () {
String result = "";
// identify array's type
// identify array's variable-name

// use the above discoveries to declare for-each-loop signature

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

return result;
}
return result;
}


public Person[] getPersonArray() {
return personArray;
public Person[] getPersonArray () {
return personArray;
}
}
}