uc 01 v2 - yshehab/SchoolRoomBooking GitHub Wiki

1. Create a permit (and a Booking) for an organization. Version 2

TO DO - Revise

Coordinating method

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

Object diagram for a typical scenario.

Walk-through for this scenario

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

  1. Check if there are any other bookings for room4 intersecting with range67 and range78.
    As the check is sucessful:
  2. Check that member5446 is a member of organization26
    As the check is sucessful:
  3. a new Booking object booking3 is created with the supplied attributes
  4. a new Permit object permit47 is created with the supplied attributes
  5. permit47 records a reference to member5446
  6. organization26 records a reference to permit47
  7. school3 records a reference to booking3 and room4
  8. school3 records a reference to permit47
  9. permit47 records a reference to booking3

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 is not linked to anOrganization 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 LettingCoord

Links
Methods

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

Pre condition: aMember should be linked via isMemberOf to anOrg. If not an exception is thrown.
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, and a new Permit object is created with the supplied attributes.

Class Room

Links
Methods
public School getSchool() 

Class School

Links

private collection<Permit> permits
private collection<Room, Booking> bookings

Methods
public void addPermit(Permit aPermit)

Post condition: permits contains aPermit

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, 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.

Class Organization

Links
Methods
public Boolean isMember(Member aMember)

Post condition: returns true if aMember is in the receiver's members, false otherwise

Class Permit

Links
private collection<Booking> bookings
Methods
Permit(Member aMember, Organization anOrg)

Post condition: a new Permit object aPermit is created with a unique number.

public void addBooking(Booking aBooking)

Post condition: the collection bookings contains aBooking

Navigations

isIn from School to Room
has from School to Booking

Discussion

superseded sequence diagram below

Sequence diagram

/images/addPermit.jpeg

Discussion

This is the valid scenario, unless there is something exciting happening with the invalid and alternate scenarios I'll just do some comments.

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