pkg core Booking - yshehab/SchoolRoomBooking GitHub Wiki

Class Description

Package

Core

Class

Booking
A Booking in the system

Attributes

private String display

Links

private collection <Range> dates

References a collection of all linked Date Range objects

private collection <Range> timeSlots

References a collection of all linked TimeSlot Range objects

Constructor

___public new(Room aRoom, Range aDateRange, Range timeslots, String display) ___

Post condition: initialises a new Booking object, aBooking, with the given attribute values. The school object linked to aRoom records a reference to aRoom and aBooking.

___public new(Room aRoom, Range aDateRange, Range timeslots, String display, Permit aPermit) ___

Post condition: initialises a new Booking object, aBooking, with the given attribute values. The school object linked to aRoom records a reference to aRoom and aBooking. aPermit records a reference to aBooking.

Protocol

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, or no dates intersect, two empty Range objects are returned.
If dates intersects but timeslots don_t, then a Range of intersecting days and an empty Range of TimeSlots is returned.
Note: we are not at this stage concerned about intersecting timeslots if dates don_t intersect. This might change??

public Boolean hasDate(Date aDate)

Post condition: returns true if the receiver_s date Range object contains aDate, returns False otherwise

___public Boolean isFuture() ___

Post condition: returns True is any of the dates in the receivers dateRange Range are today or after the current date.

___public void cancel() ___

Precondition: Precondition: one or more of the Date objects referenced by aBooking_s date attribute should be today or in the future. If not an exception is thrown.

Post-Condition: If some of the Date objects linked to the dateRange object aDateRange linked to the receiver are today or in in the future, those Date objects are removed from aDateRange.
If all the Date objects linked to the dateRange object aDateRange linked to the receiver are today or in the future then aBooking and its linked Charge, DateRange and Date objects are removed from the system.

___public BigDecimal getCost() ___

Post condition: Returns the receiver_s cost

⚠️ **GitHub.com Fallback** ⚠️