-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSessionList.java
60 lines (53 loc) · 1.37 KB
/
SessionList.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
import java.util.ArrayList;
/**
* @author Andrew Chisolm, Bryan Munoz, Matt Olson, Daniel Ruiz, Jaden Arnold
* List of all Sessions
*/
public class SessionList {
private ArrayList<Session> sessions;
private static SessionList sessionList;
/**
* Sets the session list
*/
private SessionList() {
sessions = DataReader.getAllSessions();
}
/**
* Creates a new instance of the object if necessary
* @return the current instance of the object
*/
public static SessionList getInstance() {
if (sessionList == null) {
sessionList = new SessionList();
}
return sessionList;
}
/**
* Accessor for sessions
* @return Sessions ArrayList
*/
public ArrayList<Session> getSessions() {
return this.sessions;
}
/**
* Adds a session to the list
* @param session the session being added
*/
public void addSession(Session session) {
sessions.add(session);
DataWriter.saveAllSessions();
}
/**
* Searches for a session
* @param week week of the session
* @return the session; null if not found
*/
public Session getSession(int week) {
for(Session session : sessions) {
if(session.getWeek() == week) {
return session;
}
}
return null;
}
}