I'm trying to do this. I have an enum of week days. I have used enum since weekdays are constant
public enum WeekDay {
MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY;
}
and I have a class, called Session. A session is simply what is going on at a particular time e.g. a maths class
public class Session {
// some fields
public String title;
public int duration,start,end;
/** several methods follow to get and set, and check e.t.c **/
}
There is a third class, called Venue. Venues host the sessions, e.g. the maths class can be from 9am to 10am, at a venue called "maths-class" (an example)
public class Venue { // simply a place that can hold several sessions in a day
private String name;
private int capacity;
/** several methods**/
}
What I need to do is this - create a list of sessions in the enum i.e. each day has its sessions, and then I need to hold the enums in a structure (an ArrayList or enumset?) within a venue i.e. a venue has sessions from Monday to Friday (ideally school classes). So it will be something like this:
public enum WeekDay {
MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY;
/** the list of sessions for a given day**/
private ArrayList <Session> list;
private int numOfSessions; // number of sessions
/** with some methods like **/
addSession();
removeSession();
getSession();
checkTimeOfSession();
...
}
So that in the venue, we can have:
public class Venue {
private String name;
private int capacity;
private ? <WeekDay> list; //structure to hold days, i don't know which one to use yet
/** several methods like **/
numOfSessionsOn();
getSessionsOn();
addSessionOn();
removeSessionOn();
...
}
And here are my questions:
- Can I nest the
Sessionclass within anenum? - Can an
enumacceptarraylists? - What is the best structure to hold the enums with their sessions inside the venue?
- Any better ideas for this?
Someone just told me that I'll be passing the same day to all venues regardless e.g. MONDAY is MONDAY for all venues, its list will be updated by every venue. So I think that's the end of discussion even though nobody commented.