-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomer.java
92 lines (73 loc) · 2.04 KB
/
Customer.java
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package builder;
public class Customer {
private String firstName;
private String lastName;
private String email;
private int age;
private int shoeSize;
private double yearlyIncome;
private double yearlyAmountSpendOnShoes;
private boolean isMarried;
public static class Builder{
private String firstName="";
private String lastName="";
private String email="";
private int age=0;
private int shoeSize=0;
private double yearlyIncome=0;
private double yearlyAmountSpendOnShoes=0.0;
private boolean isMarried=false;
public Builder withFirstName(String firstName) {
this.firstName=firstName;
return this;
}
public Builder withLastName(String lastName) {
this.lastName=lastName;
return this;
}
public Builder withEmail(String email) {
this.email=email;
return this;
}
public Builder withAge(int age) {
this.age=age;
return this;
}
public Builder withShoeSize(int shoeSize) {
this.shoeSize=shoeSize;
return this;
}
public Builder withYearlyIncome(int yearlyIncome) {
this.yearlyIncome=yearlyIncome;
return this;
}
public Builder withYearlyAmountSpendOnShoes(double yearlyAmountSpendOnShoes)
{
this.yearlyAmountSpendOnShoes=yearlyAmountSpendOnShoes;
return this;
}
public Builder isMarried(boolean isMarried){
this.isMarried=true;
return this;
}
public Customer build() {
return new Customer(this);
}
}
private Customer(Builder builder) {
this.firstName=builder.firstName;
this.lastName=builder.lastName;
this.email=builder.email;
this.age=builder.age;
this.shoeSize=builder.shoeSize;
this.yearlyIncome=builder.yearlyIncome;
this.yearlyAmountSpendOnShoes=builder.yearlyAmountSpendOnShoes;
this.isMarried=builder.isMarried;
}
@Override
public String toString() {
return "Customer [firstName=" + firstName + ", lastName=" + lastName + ", email=" + email + ", age=" + age
+ ", shoeSize=" + shoeSize + ", yearlyIncome=" + yearlyIncome + ", yearlyAmountSpendOnShoes="
+ yearlyAmountSpendOnShoes + ", isMarried=" + isMarried + "]";
}
}