OOP2

Added the first files for the challenge of 2016-2017.

Author
Maarten 'Vngngdn' Vangeneugden
Date
Nov. 18, 2016, 8:53 a.m.
Hash
d72af86215ff4ce4739320d66e43d0bfbca4d3ec
Parent
fb0e73da027f76aabc6aaffd74b94aff5f576f50
Modified files
Challenge/Bed.java
Challenge/Reservation.java
Challenge/Room.java

Challenge/Bed.java

25 additions and 0 deletions.

View changes Hide changes
+
1
import java.util.Set;
+
2
+
3
public class Bed {
+
4
+
5
	private Set<Date> reservedDates;
+
6
+
7
	public Bed(Set<Date> reservedDates) {
+
8
		this.reservedDates = reservedDates;
+
9
	}
+
10
+
11
	/**
+
12
	 * Checks whether this Bed can be reserved in the given period.
+
13
	 * @return True if it's free, false otherwise.
+
14
	 */
+
15
	public boolean isFree(Date begin, Date end) {
+
16
		for(Date reservedDate: this.reservedDates) {
+
17
			if(reservedDate.after(begin) && reservedDate.before(end)) {
+
18
				return false;
+
19
			}
+
20
		}
+
21
		return true;
+
22
	}
+
23
		
+
24
}
+
25

Challenge/Reservation.java

82 additions and 0 deletions.

View changes Hide changes
+
1
+
2
public class Reservation {
+
3
+
4
	private String groupName;
+
5
	private Date date;
+
6
	private Set<Bed> reservedBeds;
+
7
	private int reservationID;
+
8
	private String roomType;
+
9
	private Set<String> roomFacilities;
+
10
	private int nights;
+
11
	private int[] breakfastDays;
+
12
+
13
	public Reservation(String groupName, Date date, Set<Bed> reservedBeds, int reservationID, String roomType, Set<String> roomFacilities, int nights, int[] breakfastDays) {
+
14
		this.groupName = groupName;
+
15
		this.date = date;
+
16
		this.reservedBeds = reservedBeds;
+
17
		this.reservationID = reservationID;
+
18
		this.roomType = roomType;
+
19
		this.roomFacilities = roomFacilities;
+
20
		this.nights = nights;
+
21
	}
+
22
+
23
	public void setGroupName(String groupName) {
+
24
		this.groupName = groupName;
+
25
	}
+
26
+
27
	public String getGroupName() {
+
28
		return groupName;
+
29
	}
+
30
+
31
	public void setDate(Date date) {
+
32
		this.date = date;
+
33
	}
+
34
+
35
	public Date getDate() {
+
36
		return date;
+
37
	}
+
38
+
39
	public void setReservedBeds(Set<Bed> reservedBeds) {
+
40
		this.reservedBeds = reservedBeds;
+
41
	}
+
42
+
43
	public Set<Bed> getReservedBeds() {
+
44
		return reservedBeds;
+
45
	}
+
46
+
47
	public void setReservationID(int reservationID) {
+
48
		this.reservationID = reservationID;
+
49
	}
+
50
+
51
	public int getReservationID() {
+
52
		return reservationID;
+
53
	}
+
54
+
55
	public void setRoomType(String roomType) {
+
56
		this.roomType = roomType;
+
57
	}
+
58
+
59
	public String getRoomType() {
+
60
		return roomType;
+
61
	}
+
62
+
63
	public void setRoomFacilities(Set<String> roomFacilities) {
+
64
		this.roomFacilities = roomFacilities;
+
65
	}
+
66
+
67
	public Set<String> getRoomFacilities() {
+
68
		return roomFacilities;
+
69
	}
+
70
+
71
	public void setNights(int nights) {
+
72
		this.nights = nights;
+
73
	}
+
74
+
75
	public int getNights() {
+
76
		return nights;
+
77
	}
+
78
+
79
	// TODO breakfast get/set!
+
80
+
81
}
+
82

Challenge/Room.java

51 additions and 0 deletions.

View changes Hide changes
+
1
import java.util.HashSet;
+
2
import java.util.Date;
+
3
+
4
public class Room {
+
5
+
6
	private Set<Bed> beds;
+
7
	private String type;
+
8
	private Set<String> facilities;
+
9
+
10
	public Room(Set<Bed> beds, String type, Set<String> facilities) {
+
11
		this.beds = beds;
+
12
		this.type = type;
+
13
		this.facilities = facilities;
+
14
	}
+
15
+
16
	public void setBeds(Set<Bed> beds) {
+
17
		this.beds = beds;
+
18
	}
+
19
+
20
	public Set<Bed> getBeds() {
+
21
		return beds;
+
22
	}
+
23
+
24
	public void setType(String type) {
+
25
		this.type = type;
+
26
	}
+
27
+
28
	public String getType() {
+
29
		return type;
+
30
	}
+
31
+
32
	public void setFacilities(Set<String> facilities) {
+
33
		this.facilities = facilities;
+
34
	}
+
35
+
36
	public Set<String> getFacilities() {
+
37
		return facilities;
+
38
	}
+
39
+
40
	public Set<Bed> getEmptyBeds(Date begin, Date end) {
+
41
		Set<Bed> emptyBeds = new HashSet<>();
+
42
		for(Bed bed: this.beds) {
+
43
			if(bed.isFree(begin, end)) {
+
44
				emptyBeds.add(bed);
+
45
			}
+
46
		}
+
47
		return emptyBeds;
+
48
	}
+
49
+
50
}
+
51