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

import java.util.Arrays;

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

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

// use `counter` to identify the `current Person` in the array
// get `string Representation` of `currentPerson`
// append `stringRepresentation` to `result` variable
// use `counter` to identify the `current Person` in the array
// get `string Representation` of `currentPerson`
// append `stringRepresentation` to `result` variable
result.append(personArray[counter].toString());
counter++;

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


Expand All @@ -38,14 +44,18 @@ public String forLoop() {
// get `string Representation` of `currentPerson`
// append `stringRepresentation` to `result` variable
// end loop
for(int i=0;i< personArray.length;i++)
{
result+=personArray[i].toString();
}

return result;
}



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

Expand All @@ -54,8 +64,11 @@ public String forEachLoop() {
// get `string Representation` of `currentPerson`
// append `stringRepresentation` to `result` variable
// end loop
for(Person strArray: personArray){
result.append(strArray);
}

return result;
return result.toString();
}


Expand Down