-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathElectronic.java
More file actions
99 lines (78 loc) · 2.59 KB
/
Electronic.java
File metadata and controls
99 lines (78 loc) · 2.59 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
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
93
94
95
96
97
98
package me.day05.practice.Practice01;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Objects;
public class Electronic {
private static int serialNum = 0;
private String productNO;
private String modelName;
private Company CompanyName;
private LocalDate dateOfMade;
private Auth[] authMethod;
public Electronic(String modelName, Company companyName, Auth[] authMethod) {
serialNum++;
productNO = setProductNO();
this.modelName = modelName;
CompanyName = companyName;
this.dateOfMade = LocalDate.now();
this.authMethod = authMethod;
}
public Electronic() {
serialNum++;
productNO = setProductNO();
}
public String getProductNO() {
return productNO;
}
public String setProductNO() {
LocalDate localDate = LocalDate.now();
String serialNO = localDate.format(DateTimeFormatter.ofPattern("yyMMdd"));
serialNO += String.format("%04d",serialNum);
return serialNO;
}
public String getModelName() {
return modelName;
}
public void setModelName(String modelName) {
this.modelName = modelName;
}
public Company getCompanyName() {
return CompanyName;
}
public void setCompanyName(Company companyName) {
CompanyName = companyName;
}
public LocalDate getDateOfMade() {
return dateOfMade;
}
public void setDateOfMade(LocalDate dateOfMade) {
this.dateOfMade = dateOfMade;
}
public Auth[] getAuthMethod() {
return authMethod;
}
public void setAuthMethod(Auth[] authMethod) {
this.authMethod = authMethod;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Electronic that = (Electronic) o;
return Objects.equals(productNO, that.productNO) && Objects.equals(modelName, that.modelName) && CompanyName == that.CompanyName && Objects.equals(dateOfMade, that.dateOfMade) && authMethod == that.authMethod;
}
@Override
public int hashCode() {
return Objects.hash(productNO, modelName, CompanyName, dateOfMade, authMethod);
}
@Override
public String toString() {
return "Electronic{" +
"productNO='" + productNO + '\'' +
", modelName='" + modelName + '\'' +
", CompanyName=" + CompanyName +
", dateOfMade=" + dateOfMade +
", authMethod=" + authMethod +
'}';
}
}