- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuilderPatternExample.java
More file actions
Latest commit
45 lines (32 loc) · 791 Bytes
/
Copy pathBuilderPatternExample.java
File metadata and controls
45 lines (32 loc) · 791 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
publicclassVehicle{
publicclassBuilder{
privateStringtype;
privateStringcolor;
privateintnoOfWheels;
privateintid;
publicBuilder(intid){
this.id = id;
}
publicBuildersetType(Stringtype){
this.type = type;
returnthis;
}
publicBuildersetColor(Stringcolor){
this.color = color;
returnthis;
}
publicBuildersetNoOfWheels(intnoOfWheels){
this.noOfWheels = noOfWheels;
returnthis;
}
publicVehiclebuild(){
returnnewVehicle(this);
}
}
privateVehicle(Builderbuilder){
this.id = builder.id;
this.type = builder.type;
this.color = builder.color;
this.noOfWheels = noOfWheels;
}
}