Skip to content

PersonDeets Passed #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
26 changes: 14 additions & 12 deletions src/main/java/com/zipcodewilmington/PersonHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ public PersonHandler(Person[] personArray) {

public String whileLoop() {
String result = "";
// create a `counter`
// while `counter` is less than length of array
// begin loop

int count = 0 ; // create a `counter`
while (count < personArray.length) { // while `counter` is less than length of array
result += personArray[count].toString();
count++; // begin loop
}
// use `counter` to identify the `current Person` in the array
// get `string Representation` of `currentPerson`
// append `stringRepresentation` to `result` variable
Expand All @@ -28,12 +29,10 @@ public String whileLoop() {

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

// use the above clauses to declare for-loop signature
// begin loop
for (int i = 0; i < personArray.length; i++) {// identify initial value // identify terminal condition // identify increment // use the above clauses to declare for-loop signature // begin loop
result += personArray[i].toString();
//i++ is inside for () does not need to be repeated again
}
// use `counter` to identify the `current Person` in the array
// get `string Representation` of `currentPerson`
// append `stringRepresentation` to `result` variable
Expand All @@ -46,9 +45,12 @@ public String forLoop() {

public String forEachLoop() {
String result = "";
// identify array's type
// identify array's variable-name
int i = 0;
for (Person name : personArray) {
result += personArray[i].toString();
i++;

}
// use the above discoveries to declare for-each-loop signature
// begin loop
// get `string Representation` of `currentPerson`
Expand Down