-
Notifications
You must be signed in to change notification settings - Fork 273
Expand file tree
/
Copy pathLineName.java
More file actions
43 lines (37 loc) · 833 Bytes
/
Copy pathLineName.java
File metadata and controls
43 lines (37 loc) · 833 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
package subway.domain;
/*
* LineName
*
* version 1.0
*
* 2020.12.15
*
* Copyright (c) by Davinci.J
*/
import subway.Constants;
import java.util.Objects;
public class LineName {
private String name;
public LineName(String name) {
if (name.length() < Constants.NAME_LENGTH_LIMIT) {
throw new IllegalArgumentException(Constants.NAME_LENGTH_LIMIT_ERROR);
}
this.name = name;
}
@Override
public boolean equals(Object object) {
if (object instanceof LineName) {
LineName anotherName = (LineName) object;
return name.equals(anotherName.name);
}
return false;
}
@Override
public int hashCode() {
return Objects.hash(name);
}
@Override
public String toString() {
return name;
}
}