forked from hazukac/DesignPatterns
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFullBorder.java
More file actions
30 lines (30 loc) · 940 Bytes
/
Copy pathFullBorder.java
File metadata and controls
30 lines (30 loc) · 940 Bytes
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
public class FullBorder extends Border {
public FullBorder(Display display) {
super(display);
}
public int getColumns() {
return 1 + this.display.getColumns() + 1;
}
public int getRows() {
return 1 + this.display.getRows() + 1;
}
public String getRowText(int row) {
// さいしょの行
if (row == 0) {
return "+" + this.makeLine('-', this.display.getColumns()) + "+";
}
// さいごの行
if (row == this.display.getRows() + 1) {
return "+" + this.makeLine('-', this.display.getColumns()) + "+";
}
// それいがいの行
return "|" + this.display.getRowText(row - 1) + "|";
}
private String makeLine(char ch, int count) {
StringBuffer buf = new StringBuffer();
for (int i = 0; i < count; i++) {
buf.append(ch);
}
return buf.toString();
}
}