-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathEventList.java
100 lines (90 loc) · 2.42 KB
/
EventList.java
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
100
import java.util.ArrayList;
import java.util.UUID;
public class EventList {
private static EventList eventList = null;
public ArrayList<Event> events;
private EventList() {
this.events = DataReader.getEvents();
}
/**
*The getInstance method gets the current instance and returns it.
*Used for the singleton
* @return the current instance of evenList
*/
public static EventList getInstance() {
if (eventList == null) {
eventList = new EventList();
}
return eventList;
}
public ArrayList<Event> getEvents() {
return events;
}
/**
* creates an event object and adds it to the Event List
* @param name
* @param shortDescription
* @param categories
* @return the event
*/
public Event addEvent(String name, String shortDescription, ArrayList<Category> categories) {// Change in lucid Chart
Event event = new Event(name, shortDescription, categories);
events.add(event);
return event;
}
/**
* removes a event from the event List
* @param event
* @return the event list without the event that was removed
*/
public ArrayList<Event> removeEvent(Event event) {
events.remove(event);
return events;
}
/**
* The method allows for an Event to be searched for by the category associated to the event
* @param categories
* @return the events associated with the category searched
*/
public ArrayList<Event> searchByCategory(Category categories) {
ArrayList<Event> relevantEvents = new ArrayList<>();
for (Event e : events) {
if (e.hasCategory(categories)) {
relevantEvents.add(e);
}
}
return relevantEvents;
}
/**
* The method allows user to search events by specific name
* @param name
* @return the relevant events that have the name searched
*/
public ArrayList<Event> searchByName(String name) {
ArrayList<Event> relevantEventsName = new ArrayList<>();
for (Event e : events) {
if (e.getEventName().toLowerCase().contains(name.toLowerCase()))
;
{
relevantEventsName.add(e);
}
}
return relevantEventsName;
}
/**
* The method assigned a UUID to an event
* @param ID
* @return returns the UUID associated to the event
*/
public Event getEventByUUID(UUID ID) {
for (Event e : events) {
if (e.getEventId().equals(ID)) {
return e;
}
}
return null;
}
public void logout() {
// DataWriter.saveEvents();
}
}