-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContact.java
More file actions
53 lines (44 loc) · 1.57 KB
/
Contact.java
File metadata and controls
53 lines (44 loc) · 1.57 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
import java.io.Serializable;
import java.util.Objects;
public class Contact implements Serializable {
private static final long serialVersionUID = 1L;
private String id;
private String name;
private String phone;
private String email;
private String address;
public Contact(String id, String name, String phone, String email, String address) {
this.id = id;
this.name = name;
this.phone = phone;
this.email = email;
this.address = address;
}
// Getters
public String getId() { return id; }
public String getName() { return name; }
public String getPhone() { return phone; }
public String getEmail() { return email; }
public String getAddress() { return address; }
// Setters
public void setName(String name) { this.name = name; }
public void setPhone(String phone) { this.phone = phone; }
public void setEmail(String email) { this.email = email; }
public void setAddress(String address) { this.address = address; }
@Override
public String toString() {
return String.format("ID: %s | Name: %s | Phone: %s | Email: %s | Address: %s",
id, name, phone, email, address);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Contact contact = (Contact) o;
return Objects.equals(id, contact.id);
}
@Override
public int hashCode() {
return Objects.hash(id);
}
}