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
22 changes: 19 additions & 3 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.lang.reflect.Array;

/**
* Created by leon on 1/24/18.
*/
Expand All @@ -16,6 +18,15 @@ public String whileLoop() {
// while `counter` is less than length of array
// begin loop

// created the code using 2 kinds of iteration -- why '.append' when this code works?
/* for (int counter = 0; counter < personArray.length; counter++) {
result += personArray[counter];
} */
int counter = 0;
while (counter < personArray.length) {
result += personArray[counter];
counter++;
}
// use `counter` to identify the `current Person` in the array
// get `string Representation` of `currentPerson`
// append `stringRepresentation` to `result` variable
Expand All @@ -31,7 +42,9 @@ public String forLoop() {
// identify initial value
// identify terminal condition
// identify increment

for (int counter = 0; counter < personArray.length; counter++) {
result += personArray[counter];
}
// use the above clauses to declare for-loop signature
// begin loop
// use `counter` to identify the `current Person` in the array
Expand All @@ -42,13 +55,16 @@ public String forLoop() {
return result;
}


// how do you do forEachLoops

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

for (Person theEnd: personArray) {
result += theEnd;
}
// use the above discoveries to declare for-each-loop signature
// begin loop
// get `string Representation` of `currentPerson`
Expand Down