forked from nus-cs2103-AY2223S2/ip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEvents.java
72 lines (57 loc) · 1.9 KB
/
Events.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
package duke.tasks;
import duke.Duke;
import duke.DukeException;
import duke.Parser;
import java.time.LocalDateTime;
public class Events extends Task {
static protected String DEFAULT_TIME = "2359";
protected LocalDateTime startDate;
protected LocalDateTime endDate;
public Events(String description, String startDate, String endDate) throws DukeException {
super(description);
this.startDate = Parser.stringToDateTime(startDate);
this.endDate = Parser.stringToDateTime(endDate);
if (this.endDate.isBefore(this.startDate)) {
throw new DukeException("Event is Invalid! Your Start Date is after your EndDate!");
}
}
public String getStart() {
return Parser.dateTimeToString(startDate);
}
public String getEnd() {
return Parser.dateTimeToString(endDate);
}
@Override
public String getStatusIcon() {
return super.getStatusIcon();
}
@Override
public String getDescription() {
return super.getDescription();
}
public String parseStartSaving() {
return Parser.dateTimeSaving(startDate);
}
public String parseEndSaving() {
return Parser.dateTimeSaving(startDate);
}
/**
* Produces a String that adheres to our Storage formatting
* holding all the relevant information.
*
* @return the String of the specific task for saving
*/
@Override
public String saveString() {
return String.format("E|%s|%s|%s|%s", super.saveString(), super.description,
this.parseStartSaving(), this.parseEndSaving());
}
/**
* All the Information of the Event task
*
* @return a String of all the information of the Event task to be printed by the Ui
*/
public String toString() {
return String.format("[E]%s (from: %s to: %s)", super.toString(), this.getStart(), this.getEnd());
}
}