-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuilder_Pattern
More file actions
61 lines (53 loc) · 962 Bytes
/
Builder_Pattern
File metadata and controls
61 lines (53 loc) · 962 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Builder Pattern:
public class Bird {
private int wt;
private String name;
private String type;
public Bird(Builder obj) {
this.wt=obj.getWt();
this.name=obj.getName();
this.type=obj.getType();
}
public int getWt() {
return this.wt;
}
public String getName() {
return this.name;
}
public String getType() {
return this.type;
}
static class Builder {
private int wt;
private String name;
private String type;
public Builder(String name) {
this.name=name;
}
public Builder setWt(int wt) {
this.wt=wt;
return this;
}
public Builder setName(String name) {
this.name=name;
return this;
}
public Builder setType(String type) {
this.type=type;
return this;
}
public int getWt() {
return this.wt;
}
public String getName() {
return this.name;
}
public String getType() {
return this.type;
}
public Bird build() {
Bird b=new Bird(this);
return b;
}
}
}