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
61 changes: 39 additions & 22 deletions src/main/java/com/zipcodewilmington/PersonHandler.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.zipcodewilmington;

import java.lang.reflect.Array;
import java.util.ArrayList;

/**
* Created by leon on 1/24/18.
*/
Expand All @@ -11,55 +14,69 @@ public PersonHandler(Person[] personArray) {
}

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

// create a `counter`
// while `counter` is less than length of array
// begin loop
// begin loop

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

// end loop

String result = "";
int i = 0;
while (i < personArray.length) {

String currentPerson = personArray[i].toString();
result += currentPerson;

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

// end loop
return result;
}



public String forLoop() {
String 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

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



public String forEachLoop() {
String result = "";
// identify array's type
// identify array's variable-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
// begin loop
// get `string Representation` of `currentPerson`
// append `stringRepresentation` to `result` variable
// end loop

return result;
}
for (Person people : personArray) {
String currentPeople = people.toString();
result+=currentPeople;

}
return result;

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