Whitney Martinez 6 anos atrás
pai
commit
f6f66e1a9b

+ 4
- 30
src/main/java/rocks/zipcode/io/quiz4/objectorientation/StringAssembler.java Ver arquivo

9
 public class StringAssembler {
9
 public class StringAssembler {
10
     Character ch;
10
     Character ch;
11
     String str;
11
     String str;
12
+    StringBuilder sb = new StringBuilder();
12
 
13
 
13
     public StringAssembler(Character delimeter) {
14
     public StringAssembler(Character delimeter) {
14
 
15
 
22
     }
23
     }
23
 
24
 
24
     public StringAssembler append(String str) {
25
     public StringAssembler append(String str) {
25
-
26
-        int counter = 0;
27
-        String st = "";
28
-        StringBuilder sb = new StringBuilder();
29
-        List<String> list = new ArrayList<String>();
30
-
31
-            if(str != null) {
32
-                list.add(str);
33
-            }
34
-        for (int i = 0; i < list.size() ; i++) {
35
-
36
-            sb.append(str);
37
-        }
38
-
39
-        st = sb.toString();
40
-
41
-        StringAssembler sA = new StringAssembler(st);
42
-
43
-        return sA;
44
-
45
-
26
+            sb.append(str).append(this.ch);
27
+            return this;
46
     }
28
     }
47
 
29
 
48
     public String assemble() {
30
     public String assemble() {
49
 
31
 
50
-        StringBuffer sb = new StringBuffer();
51
-        String r = "";
52
-
53
-
54
-        sb.append(ch);
55
-
56
-
57
-        r = sb.toString();
58
-        return r;
32
+        return sb.deleteCharAt(this.sb.length() -1).toString();
59
     }
33
     }
60
 }
34
 }