uc 08 - yshehab/SchoolRoomBooking GitHub Wiki

8. View all bookings for a given room

Coordinating method

Collection<Booking> getBookings(Room aRoom)

Object diagram for a typical scenario.

Walk-through for this scenario

Given: The Room object, room356

  1. Access the school object linked to room356, which in this case is school3
  2. Create a new empty collection, results.
  3. Access the collection of Booking objects in school3 linked to room356, which in this case is {booking38, booking55, booking 82}.
  4. For each Booking object accessed in step3, check if it is today or in the future.
  5. If it is, add the Booking object to results
  6. Return results

Sequence diagram for this scenario

Notes on alternative scenarios

If there are no Bookings linked to an Room then return an empty collection
If all Bookings linked to a Room are in the past then return an empty collection

Updates to implementation model

Classes

Class Booking

Links
Methods
public Boolean isFuture()

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

Class Room

Links

private School school

Methods
public collection <Booking> getBookings()

Post condition: returns a collection of Booking objects for the current day and the future which are linked to the receiver

Class School

Links
private collection<Room, Booking> bookings
Methods
public collection<Booking> getBookings(Room aRooom)

Post condition: returns aCollection of the Booking objects linked to aRoom

Class LettingCoord

Links
Methods
Collection<Booking> getBookings(Room aRoom)

Post condition: returns a collection of Booking objects which are linked to aRoom

Navigations

isIn from Room to School
isIn from School to Room
has from School to Booking

Discussion

Note: Do we include the current day as in the future?? Yes - updated to include today as the future.

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