-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathName.java
More file actions
40 lines (34 loc) · 879 Bytes
/
Name.java
File metadata and controls
40 lines (34 loc) · 879 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
public class Name {
private String first;
private String last;
public Name() {
this("","");
}
public Name(String first, String last) {
this.first = first;
this.last = last;
}
public Name(Name origName) {
this.first = origName.first;
this.last = origName.last;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof Name) {
Name other = (Name) obj;
return this.first.equals(other.first) && this.last.equals(other.last);
}
return false;
}
@Override
public String toString() {
return first + " " + last;
}
public static Name read(java.util.Scanner sc) {
if (sc.hasNext()) {
Name newName = new Name(sc.next(), sc.next());
return newName;
}
return null;
}
}