uc 02 v2 - yshehab/SchoolRoomBooking GitHub Wiki

2. Add a booking. Version 2

TO DO - revise

Coordinating method

public collection<Range> addBooking(Member aMember, Room aRoom, Range dateRange, Range timeslots, String display)

Object diagram for a typical scenario.

Walk-through for this scenario

Given: The Member object, member2 the Room object room4, the Range object range67, the Range object range78 and the string "Yoga".

  1. Check if member2 is linked to the School object linked to room4, which is school3.
    As member2 is linked to school3:
  2. Check if there are any other bookings for room4 intersecting with range67 and range78.
    As the check is sucessful:
  3. a new Booking object booking3 is created with the supplied attributes
  4. school3 records a reference to booking3 and room4 (Neo "I see a Map Room, Booking as an attribute of School")

Note: this makes isFor a derived association, as we have Map <Room, Booking> as an attribute of School

Sequence diagram for this scenario

Notes on alternative scenario

  • If aMember does not work at 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.

Updates to implementation model

Classes

Class Room

Links
private School school
Methods
public School getSchool()

Class School

Links

private collection<Member> members
private collection<Room, Booking> bookings

Methods
public Boolean isMember(Member aMember)

Post condition: returns true if aMember works at 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)

Class Booking

Links
Methods

public new(Room aRoom, Range aDateRange, Range timeslots, String display)

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.

Class LettingCoord

Links

None

Methods

public collection<Range> addBooking(Member aMember, 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.

Navigations

isIn from School to Room
has from School to Booking

Discussion

Note: At this stage we do not need to keep a reference to which member made this booking. The implication being that a school does not need to know who has booked a room, if a member of staff has booked it.

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