-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEvent.java
More file actions
91 lines (72 loc) · 2.45 KB
/
Event.java
File metadata and controls
91 lines (72 loc) · 2.45 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
import java.util.*;
public class Event {
private boolean isEvent;
private String eventTitle;
private String dateTime;
private String location;
private BST<Contact> contacts;
public Event() {
this(true, "Untitled Event", "", "", new BST<>());
}
public Event(boolean isEvent, String eventTitle, String dateTime, String location, BST<Contact> contacts) {
this.isEvent = isEvent;
this.eventTitle = (eventTitle != null) ? eventTitle : "Untitled Event";
this.dateTime = dateTime;
this.location = location;
this.contacts = (contacts != null) ? contacts : new BST<>();
}
public boolean isEvent() {
return isEvent;
}
public String getEventType() {
return isEvent ? "Event" : "Appointment";
}
public String getEventTitle() {
return eventTitle;
}
public String getDateTime() {
return dateTime;
}
public String getLocation() {
return location;
}
public BST<Contact> getContacts() {
return contacts;
}
public void setEvent(boolean event) {
isEvent = event;
}
public void setEventTitle(String eventTitle) {
this.eventTitle = eventTitle;
}
public void setDateTime(String dateTime) {
this.dateTime = dateTime;
}
public void setLocation(String location) {
this.location = location;
}
public void setContacts(BST<Contact> contacts) {
this.contacts = contacts;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getEventType()).append(": ").append(eventTitle != null ? eventTitle : "N/A");
sb.append("\nTime: ").append(dateTime != null ? dateTime : "N/A");
sb.append("\nLocation: ").append(location != null ? location : "N/A");
sb.append("\nContacts Involved:");
if (contacts == null || contacts.isEmpty()) {
sb.append("\n None");
} else {
List<Contact> contactList = contacts.getAllDataInOrder();
if (contactList.isEmpty()) {
sb.append("\n None (Error retrieving contacts)");
} else {
for(Contact c : contactList) {
sb.append("\n - ").append(c.getContactName());
}
}
}
return sb.toString();
}
}