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

public String whileLoop() {
String result = "";
int count = 0;
while (count < personArray.length) {
for (int i = 0; i < personArray.length; i++) {
result += personArray[count].toString();
count++;

} return result;
}
// create a `counter`
// while `counter` is less than length of array
// begin loop
Expand All @@ -28,6 +36,12 @@ public String whileLoop() {

public String forLoop() {
String result = "";
//int count = 0;
for (int counter = 0 ; counter < personArray.length; counter++) {
// count++;
String currentPerson = personArray[counter].toString(); //use counter to identify current person
result += currentPerson;
}
// identify initial value
// identify terminal condition
// identify increment
Expand All @@ -46,6 +60,15 @@ public String forLoop() {

public String forEachLoop() {
String result = "";
int i = 0;
Person person = personArray[i];


for (Person currentPerson : personArray) { //for each loop (variable , array)
String newPerson = currentPerson.toString();
result += newPerson;
}

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

Expand Down