forked from hazukac/DesignPatterns
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTextBuilder.java
More file actions
33 lines (31 loc) · 1.08 KB
/
Copy pathTextBuilder.java
File metadata and controls
33 lines (31 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// public class TextBuilder extends Builder {
public class TextBuilder implements Builder {
private StringBuffer buffer = new StringBuffer();
private StringBuffer titleBuffer = new StringBuffer();
private StringBuffer result = new StringBuffer();
public void makeTitle(String title) {
titleBuffer = new StringBuffer();
titleBuffer.append("=======================\n");
titleBuffer.append(" [" + title + "]\n");
titleBuffer.append("\n");
}
public void makeString(String str) {
buffer.append('■' + str + "\n");
buffer.append("\n");
}
public void makeItems(String[] items) {
for (int i = 0; i < items.length; i++) {
buffer.append(" ・" + items[i] + "\n");
}
buffer.append("\n");
}
public void close() {
// StringBuffer result = new StringBuffer();
result.append(titleBuffer.toString());
result.append(buffer.toString());
result.append("==========================\n");
}
public String getResult() {
return result.toString();
}
}