uc 22 - yshehab/SchoolRoomBooking GitHub Wiki

22. Add a new member to an existing school and existing organization

Coordinating method

public void addMember(Name aName, Address anAddress, Email anEmail, School aSchool, Organization anOrganization)

Object diagram for a typical scenario.

Walk-through for this scenario

Given: The Name object aName, the Address object anAddress, the Email object anEmail, the School object school3 and the Organization object organization35.

  1. Check that no Member object with the supplied attributes exists (linked to any Schools or Organizations in the system)
    As the check suceeds:
  2. A new Member object member6 is created with the supplied attributes
  3. member6 is linked to organization35
  4. member6 is linked to school3

Sequence diagram for this scenario

Notes on alternative scenario

If the Member already exists then throw an exception

Updates to implementation model

Classes

Class LettingCoord

Links
  • private collection <School> school

  • References a collection of all linked School objects

  • private collection <Organization> organizations

  • References a collection of all linked Organization objects

Methods
  • public void addMember(Name aName, Address anAddress, Email anEmail, School aSchool, Organization anOrganization)
  • Postcondition: If a Member obect exists in the system with the supplied attributes an exception is thrown, otherwise a new Member object, aMember, is created with the supplied attributes. aSchool records a reference to aMember and anOrganization records a reference to aMember

Class School

Links
  • private Collection<Member> members
Methods
  • public Boolean hasMember(Name aName, Address anAddress, Email anEmail)

  • Postcondition: returns True if the receivers members contains a Member with the supplied attributes

  • public Boolean addMember(aMember)

  • Postcondition: a reference to aMember is recorded.

Class Organization

Links
  • private Collection<Member> members
Methods
  • public Boolean hasMember(Name aName, Address anAddress, Email anEmail)

  • Postcondition: returns True if the receivers members contains a Member with the supplied attributes

  • public Boolean addMember(aMember)

  • Postcondition: a reference to aMember is recorded.

Class Member

Links
  • none
Methods
  • Member(Name aName, Address anAddress, Email anEmail)
    Post condition: a new Member object aMember is created. A reference to aMember is returned

Navigations

  • isMemberOf from Organization to Member
  • worksAt from School to Member

Discussion

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