-
Notifications
You must be signed in to change notification settings - Fork 738
Expand file tree
/
Copy pathHorizontalLine.java
More file actions
44 lines (33 loc) · 1.27 KB
/
HorizontalLine.java
File metadata and controls
44 lines (33 loc) · 1.27 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
34
35
36
37
38
39
40
41
42
43
44
package ladder.domain;
import ladder.exception.IllegalHorizontalLineHeightException;
public class HorizontalLine {
static final int MINIMUM_HEIGHT = 0;
private final AdjacentVerticalLines adjacentVerticalLines;
private final int height;
public HorizontalLine(AdjacentVerticalLines adjacentVerticalLines, int height) {
checkHeight(height);
this.adjacentVerticalLines = adjacentVerticalLines;
this.height = height;
}
private void checkHeight(int height) {
if (height < MINIMUM_HEIGHT) {
throw new IllegalHorizontalLineHeightException(String.format("최소 높이 : %d", MINIMUM_HEIGHT));
}
}
public AdjacentVerticalLines getAdjacentVerticalLines() {
return adjacentVerticalLines;
}
public int getHeight() {
return height;
}
public VerticalLine getLeftVerticalLine() {
return adjacentVerticalLines.getLeftVerticalLine();
}
public VerticalLine getRightVerticalLine() {
return adjacentVerticalLines.getRightVerticalLine();
}
public boolean isConnected(VerticalLine verticalLine) {
return verticalLine == adjacentVerticalLines.getLeftVerticalLine()
|| verticalLine == adjacentVerticalLines.getRightVerticalLine();
}
}