-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReservation.java
More file actions
58 lines (49 loc) · 1.73 KB
/
Reservation.java
File metadata and controls
58 lines (49 loc) · 1.73 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
public class Reservation implements Comparable<Reservation>{ //Used to define request/borrow object, specify the reservation period and member
private Day startDay;
private Day endDay;
private String mID;
public String returnID(){
return this.mID;
}
@Override
public int compareTo(Reservation another){ //enable easier sorting of Requests
int c = startDay.compareTo(another.startDay);
if (c == 0){c = endDay.compareTo(another.endDay);}
return c;
}
public Reservation(Day s, Day e, String m){
this.startDay = s;
this.endDay = e;
this.mID = m;
}
public Reservation(){
this.startDay = SystemDate.getInstance().clone();
this.endDay = SystemDate.getInstance().clone();
this.mID = null;
}
public void set(Day s, Day e, String m){ //change the borrow details for an item
this.startDay = s;
this.endDay = e;
this.mID = m;
}
public void reset(){ //make the set avaliable for borrow again
this.startDay = SystemDate.getInstance();
this.endDay = SystemDate.getInstance();
this.mID = null;
}
public Boolean equals(Day s, Day e, String m){
if (((this.endDay.compareTo(e) == 0) && (this.startDay.compareTo(s) == 0)) && (this.mID.compareTo(m) == 0)){
return true;
}
else{
return false;
}
}
public Boolean checkIfConflict(Day s, Day e){ //very important for checking period overlaps among requests and borrow
return (this.startDay.compareTo(e) <= 0) && (s.compareTo(this.endDay) <= 0);
}
@Override
public String toString(){
return startDay.toString() + " to " + endDay.toString();
}
}