Commit 56ac10c8 authored by s7_spruge_k's avatar s7_spruge_k
Browse files

Merge branch 'event' into 'master'

Event

See merge request s7_spruge_k/calendar!1
parents 5fdbf143 f6bbb653
package com.example.calendar;
import java.sql.Date;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.example.models.Event;
import com.example.models.EventType;
@SpringBootApplication
public class CalendarApplication {
public static void main(String[] args) {
SpringApplication.run(CalendarApplication.class, args);
System.out.println("test");
System.out.println("Event test");
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);
}
}
package com.example.models;
import java.util.ArrayList;
import java.util.Date;
public class Event {
private String name;
private String description;
private Date startDate;
private Date endDate;
private int event_ID;
private EventType eventType;
private boolean isAllDayEvent;
//TODO Discuss allEvents in Hospital class??
private static ArrayList<Event> allEvents;
private static int eventCounter = 0;
//Constructor, all parameters
public Event(String name, String description, Date startDate, Date endDate, 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) {
this.event_ID = eventCounter;
eventCounter++;
setName(name);
setDescription(description);
setStartDate(startDate);
setEndDate(endDate);
setAllDayEvent(isAllDayEvent);
}
//Constructor no description or eventType
public Event(String name, Date startDate, Date endDate, 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;
}
//Name can be contain any symbols.
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
//Description can contain any symbols
public void setDescription(String description) {
this.description = description;
}
public Date getStartDate() {
return startDate;
}
//Cannot be previous date
public void setStartDate(Date startDate) {
Date currentDate = new Date();
if(startDate.compareTo(currentDate) > 0)
{
this.startDate = startDate; //startDate is after currentDate
}
else
{
//TODO What to do when incorrect date entered?
System.out.println("StartDate is before currentDate");
}
}
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;
}
//Verification not needed
public void setEventType(EventType eventType) {
this.eventType = eventType;
}
public boolean isAllDayEvent() {
return isAllDayEvent;
}
public void setAllDayEvent(boolean isAllDayEvent) {
this.isAllDayEvent = isAllDayEvent;
}
@Override
public String toString() {
return "Event: " + name + ", description: " + description + " startDate: " + startDate + ", endDate: "
+ endDate + ", event_ID: " + event_ID + " is all day event? " + isAllDayEvent;
}
}
package com.example.models;
public enum EventType {
Birthday, Lecture, Appointment, Reminder, Meeting
}
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