uc 03 v2 - yshehab/SchoolRoomBooking GitHub Wiki
TO DO - revise
public collection<Range> addBooking(Permit aPermit, Room aRoom, Range dateRange, Range timeslots, String display)
Given: The Permit object permit47, the Room object room4, the Range object range67, the Range object range78 and the string "Yoga".
- Check if permit47 is linked to the School object linked to room4, which is school3.
As permit47 is linked to school3:
- Check if there are any other bookings for room4 intersecting with range67 and range78.
As the check is sucessful:
- a new Booking object booking3 is created with the supplied attributes
- school3 records a reference to booking3 and room4
- permit47 records a reference to booking3
Note: this makes isFor a derived association, as we have Map <Room, Booking>
as an attribute of School
- If aPermit is not linked to the School that aRoom is linked to then throw an exception.
- If there are any other bookings for room4 intersecting with range67 and range78 then two range objects are returned, one of intersecting dates and one of intersecting timeslots.
private School school
public School getSchool()
private collection<Permit> permits
private collection<Room, Booking> bookings
public Boolean hasPermit(Permit aPermit)
Post condition: returns true if aPermit is issued for the receiving school, False otherwise.
public collection<Booking> getBookings(Room aRoom)
Post condition: returns the collection of Booking objects linked to aRoom
Note: we currently only need future bookings
public void addBooking(Room aRoom, Booking aBooking)
Post condition: the collection bookings contains (aRoom, aBooking)
public new(Room aRoom, Range aDateRange, Range timeslots, String display, Permit aPermit)
Post condition: a new Booking object aBooking is created, a Permit records a reference to aBooking. The School object linked to aRoom records a reference to aRoom and aBooking.
public collection<Range> intersectsWith(Range aDaterange, Range timeslots)
Post condition: a collection of two Range objects is returned, one containing intersecting days and one intersecting timeslots. If there are no intersections two empty Range objects are returned.
None
public collection<Range> addBooking(Permit aPermit, Room aRoom, Range aDateRange, Range timeslots, String display)
Post condition: a collection of two Range objects is returned, one containing intersecting days and one intersecting timeslots. If there are no intersections two empty Range objects are returned and a new Booking object is created with the supplied attributes.
private collection<Booking> bookings
public void addBooking(Booking aBooking)
Post condition: the collection bookings contains aBooking
isIn from School to Room
has from School to Booking
hasPermits from School to Permit