Commit 8a3e2d6f authored by s7_spruge_k's avatar s7_spruge_k
Browse files

Merge branch 'event' into 'master'

Updated Event class - removed endDate

See merge request s7_spruge_k/calendar!2
parents 56ac10c8 39b9682d
......@@ -20,11 +20,7 @@ public class CalendarApplication {
Date startingDate = new Date(2019, 05, 11);
Date endingDate = new Date(2019, 05, 12);
Event e1 = new Event("Meeting No1", "Test event", startingDate, endingDate, EventType.Meeting, false);
System.out.println(e1);
Event e2 = new Event("Meeting No1", "Test event", startingDate, endingDate, EventType.Meeting, false);
System.out.println(e2);
}
}
......@@ -8,56 +8,60 @@ public class Event {
private String name;
private String description;
private Date startDate;
private Date endDate;
private int event_ID;
private int event_ID; //Auto-generated with JPA?
private EventType eventType;
private boolean isAllDayEvent;
//TODO Discuss allEvents in Hospital class??
private static ArrayList<Event> allEvents;
private static int eventCounter = 0;
// CHANGES
// Removed allevent arrayList
// removed EndDate
//Constructor, all parameters
public Event(String name, String description, Date startDate, Date endDate, EventType eventType, boolean isAllDayEvent) {
public Event(String name, String description, Date startDate, EventType eventType, boolean isAllDayEvent) {
this.event_ID = eventCounter;
eventCounter++;
setName(name);
setDescription(description);
setStartDate(startDate);
setEndDate(endDate);
setAllDayEvent(isAllDayEvent);
this.eventType = eventType;
}
//Constructor, no event type
public Event(String name, String description, Date startDate, Date endDate, boolean isAllDayEvent) {
public Event(String name, String description, Date startDate, boolean isAllDayEvent) {
this.event_ID = eventCounter;
eventCounter++;
setName(name);
setDescription(description);
setStartDate(startDate);
setEndDate(endDate);
setAllDayEvent(isAllDayEvent);
}
//Constructor no description
public Event(String name, Date startDate, EventType eventType, boolean isAllDayEvent) {
this.event_ID = eventCounter;
eventCounter++;
this.eventType = eventType;
setName(name);
setStartDate(startDate);
setAllDayEvent(isAllDayEvent);
}
//Constructor no description or eventType
public Event(String name, Date startDate, Date endDate, boolean isAllDayEvent) {
public Event(String name, Date startDate, boolean isAllDayEvent) {
this.event_ID = eventCounter;
eventCounter++;
setName(name);
setStartDate(startDate);
setEndDate(endDate);
setAllDayEvent(isAllDayEvent);
}
//Set & Get
//TODO Discuss Name/description max length?
//TODO unit test
//TODO can't be all day even if endDate is different day -> startDate.day == endDate.day???
public String getName() {
return name;
......@@ -97,44 +101,11 @@ public class Event {
}
}
public Date getEndDate() {
return endDate;
}
//Cannot be previous date or before startDate
public void setEndDate(Date endDate) {
Date currentDate = new Date();
//Checks if endDate is after currentDate
if(endDate.compareTo(currentDate) > 0)
{
//Checks if endDate is after startDate
if(endDate.compareTo(this.startDate) > 0)
{
this.endDate = endDate;
}
else
{
System.out.println("endDate is before startDate");
}
}
else
{
//TODO What to do when incorrect date entered?
System.out.println("EndDate is before currentDate");
}
}
public int getEvent_ID() {
return event_ID;
}
public static ArrayList<Event> getAllEvents() {
return allEvents;
}
public EventType getEventType() {
return eventType;
}
......@@ -154,8 +125,7 @@ public class Event {
@Override
public String toString() {
return "Event: " + name + ", description: " + description + " startDate: " + startDate + ", endDate: "
+ endDate + ", event_ID: " + event_ID + " is all day event? " + isAllDayEvent;
return "Event: " + name + ", description: " + description + " startDate: " + startDate + ", event_ID: " + event_ID + " is all day event? " + isAllDayEvent;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment