-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathElectronic.java
More file actions
56 lines (48 loc) · 1.8 KB
/
Electronic.java
File metadata and controls
56 lines (48 loc) · 1.8 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
package me.day05;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Arrays;
import java.util.Objects;
public class Electronic {
private String productNo;
private String modelName;
private Company company;
private LocalDateTime dateOfMade;
AuthMethod[] authMethod;
private static int AUTO_GEN = 0;
Electronic() {
AUTO_GEN++;
dateOfMade = LocalDateTime.now(ZoneId.systemDefault());
productNo = String.format("%02d", this.dateOfMade.getYear()) +
String.format("%02d", this.dateOfMade.getMonthValue()) +
String.format("%02d", this.dateOfMade.getDayOfMonth()) +
String.format("%04d", AUTO_GEN);
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
Electronic electronic = (Electronic) obj;
return Objects.equals(productNo, electronic.productNo)
&& Objects.equals(modelName, electronic.modelName)
&& company == electronic.company
&& Objects.equals(dateOfMade, electronic.dateOfMade)
&& Arrays.equals(authMethod, electronic.authMethod);
}
@Override
public int hashCode() {
int result = Objects.hash(productNo, modelName, company, dateOfMade);
result = 31 * result + Arrays.hashCode(authMethod);
return result;
}
@Override
public String toString() {
return "Electronic{" +
"productNo='" + productNo + '\'' +
", modelName='" + modelName + '\'' +
", companyName=" + company +
", dateOfMade=" + dateOfMade +
", authMethod=" + Arrays.toString(authMethod) +
'}';
}
}