-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContact.java
More file actions
99 lines (77 loc) · 2.55 KB
/
Contact.java
File metadata and controls
99 lines (77 loc) · 2.55 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
99
import java.util.*;
public class Contact {
private String contactName;
private String phoneNumber;
private String emailAddress;
private String address;
private String birthday;
private String notes;
public Contact(String contactName, String phoneNumber, String emailAddress, String address, String birthday, String notes) {
this.contactName = contactName;
this.phoneNumber = phoneNumber;
this.emailAddress = emailAddress;
this.address = address;
this.birthday = birthday;
this.notes = notes;
}
public Contact() {
this("", "", "", "", "", "");
}
public String getContactName() {
return contactName;
}
public String getFirstName() {
if (contactName == null || contactName.trim().isEmpty()) {
return "";
}
String trimmedName = contactName.trim();
int firstSpaceIndex = trimmedName.indexOf(" ");
if (firstSpaceIndex == -1) {
return trimmedName;
} else {
return trimmedName.substring(0, firstSpaceIndex);
}
}
public String getPhoneNumber() {
return phoneNumber;
}
public String getEmailAddress() {
return emailAddress;
}
public String getAddress() {
return address;
}
public String getBirthday() {
return birthday;
}
public String getNotes() {
return notes;
}
public void setContactName(String contactName) {
this.contactName = contactName;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public void setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
}
public void setAddress(String address) {
this.address = address;
}
public void setBirthday(String birthday) {
this.birthday = birthday;
}
public void setNotes(String notes) {
this.notes = notes;
}
@Override
public String toString() {
return "Name: " + (contactName != null ? contactName : "N/A") +
"\nPhone Number: " + (phoneNumber != null ? phoneNumber : "N/A") +
"\nEmail Address: " + (emailAddress != null ? emailAddress : "N/A") +
"\nAddress: " + (address != null ? address : "N/A") +
"\nBirthday: " + (birthday != null ? birthday : "N/A") +
"\nNotes: " + (notes != null ? notes : "N/A");
}
}