-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFullBorder.java
More file actions
37 lines (30 loc) · 863 Bytes
/
Copy pathFullBorder.java
File metadata and controls
37 lines (30 loc) · 863 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
31
32
33
34
35
36
37
package decorator;
public class FullBorder extends Border {
public FullBorder(Display display) {
super(display);
}
@Override
public int getRows() {
return 1 + display.getRows() + 1;
}
@Override
public int getColumns() {
return 1 + display.getColumns() + 1;
}
@Override
public String getRowText(int row) {
if (row == 0)
return "+" + makeLine('-', display.getColumns());
else if (row == display.getRows() + 1)
return "+" + makeLine('-', display.getColumns());
else
return "|" + display.getRowText(row - 1) + "|";
}
private String makeLine(char ch, int count) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < count; i++) {
sb.append(ch);
}
return sb.toString();
}
}