#35 Elliott Stansbury PersonDetails

Abierta
ElliottStansbury desea fusionar 1 commits de ElliottStansbury/CR-MesoLabs-Arrays-PersonDetails:master en master
Se han modificado 1 ficheros con 56 adiciones y 0 borrados
  1. 56
    0
      src/main/java/com/zipcodewilmington/PersonHandler.java

+ 56
- 0
src/main/java/com/zipcodewilmington/PersonHandler.java Ver fichero

@@ -10,8 +10,32 @@ public class PersonHandler {
10 10
         this.personArray = personArray;
11 11
     }
12 12
 
13
+
14
+
13 15
     public String whileLoop() {
14 16
         String result = "";
17
+        int counter = 0;
18
+
19
+        StringBuilder stringRepresentation = new StringBuilder(result);
20
+
21
+        while(counter < personArray.length){
22
+
23
+
24
+
25
+            Person currentPerson = personArray[counter];
26
+            String x = currentPerson.toString();
27
+
28
+
29
+
30
+            stringRepresentation.append(x);
31
+            counter++;
32
+
33
+
34
+        }
35
+
36
+        System.out.println(stringRepresentation);
37
+        System.out.println(result);
38
+        result = stringRepresentation.toString();
15 39
         // assume there is a `counter`
16 40
         // while `counter` is less than length of array
17 41
             // begin loop
@@ -28,6 +52,23 @@ public class PersonHandler {
28 52
 
29 53
     public String forLoop() {
30 54
         String result = "";
55
+        int counter = 0;
56
+
57
+        StringBuilder stringRepresentation = new StringBuilder(result);
58
+
59
+        for(int i = 0; i < personArray.length; i++){
60
+            Person currentPerson = personArray[i];
61
+            String x = currentPerson.toString();
62
+
63
+
64
+
65
+            stringRepresentation.append(x);
66
+            counter++;
67
+
68
+        }
69
+
70
+        result = stringRepresentation.toString();
71
+
31 72
         // identify initial value
32 73
         // identify terminal condition
33 74
         // identify increment
@@ -46,6 +87,21 @@ public class PersonHandler {
46 87
 
47 88
     public String forEachLoop() {
48 89
         String result = "";
90
+        StringBuilder stringRepresentation = new StringBuilder();
91
+
92
+        for(Person currentPerson : personArray){
93
+
94
+            //Person currentPerson = personArray;
95
+            String x = currentPerson.toString();
96
+
97
+
98
+
99
+            stringRepresentation.append(x);
100
+
101
+        }
102
+
103
+        result = stringRepresentation.toString();
104
+
49 105
         // identify array's type
50 106
         // identify array's variable-name
51 107