-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHouse.java
More file actions
41 lines (34 loc) · 1.01 KB
/
Copy pathHouse.java
File metadata and controls
41 lines (34 loc) · 1.01 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
public class House {
private final String walls;
private final String roof;
private final int windows;
private House(HouseBuilder builder) {
this.walls = builder.walls;
this.roof = builder.roof;
this.windows = builder.windows;
}
@Override
public String toString() {
return "House [walls=" + walls + ", roof=" + roof + ", windows=" + windows + "]";
}
public static class HouseBuilder {
private String walls;
private String roof;
private int windows;
public HouseBuilder setWalls(String walls) {
this.walls = walls;
return this;
}
public HouseBuilder setRoof(String roof) {
this.roof = roof;
return this;
}
public HouseBuilder setWindows(int windows) {
this.windows = windows;
return this;
}
public House build() {
return new House(this);
}
}
}