-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimeInterval.java
More file actions
60 lines (53 loc) · 1.38 KB
/
Copy pathTimeInterval.java
File metadata and controls
60 lines (53 loc) · 1.38 KB
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
package hw1;
import java.time.LocalDateTime;
import java.time.LocalTime;
/**
* TimeInterval class that creates an object with two local time variables
* to hold a start time and end time for an event object
* @author BrandonAmazing
* @version 1.0
*/
public class TimeInterval
{
LocalTime StartTime;
LocalTime EndTime;
/**
* TimeInterval - the constructor to create the time interval object
* @param start - the start time of the interval
* @param end - the end time of the interval
*/
public TimeInterval(LocalTime start, LocalTime end)
{
StartTime = start;
EndTime = end;
}
/**
* getStartTime - returns the start time of the time interval
* @return StartTime - the start time instance variable of the interval object
*/
public LocalTime getStartTime()
{
return StartTime;
}
/**
* getEndTime - returns the end time of the time interval
* @return EndTime - the end time instance variable of the interval object
*/
public LocalTime getEndTime()
{
return EndTime;
}
/**
* conflict - checks if there is a conflict between two time intervals
* @param t - the time interval to compare to
* @return true if there is a conflict, false if there is no conflict
*/
public boolean conflict (TimeInterval t)
{
if (t.getStartTime().isBefore(this.getEndTime()) && t.getEndTime().isAfter(this.getStartTime()))
{
return true;
}
return false;
}
}