uc 23 - yshehab/SchoolRoomBooking GitHub Wiki

23. Add a new member and a new organization

Coordinating method

public void addMemberAndOrganization(Name memberName, Address memberAddress, Email anEmail, String orgName, Address orgAddress)

Object diagram for a typical scenario.

Walk-through for this scenario

Given: The Name object memberName, the Address object address4, the Email object anEmail, the String "Yoga" and the Address object address6

  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. Check that an organization with name "Yoga" doesn_t exist linked to address6 (this check is not needed for this scenario , but is for the alternative scenario)
    As the check suceeds:
  3. A new Member object member62 is created with the supplied attributes
  4. A new Organization object organization3 is created with the supplied attributes
  5. letting records a reference to organization3
  6. organization3 records a reference to member62

Sequence diagram for this scenario

Notes on alternative scenarios

If the Member already exists then throw an exception
If an Organization with the same name is linked to the same address object, throw an exception
Note: it is valid for the address objects for the member and organization to be the same

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 addMemberAndOrganization(Name memberName, Address memberAddress, Email anEmail, String orgName, Address orgAddress)
  • Postcondition: If a Member object exists in the system with the supplied attributes or if anOrganization with the same name is linked to the same address object, an exception is thrown, otherwise a new Member object, aMember, is created with the supplied attributes, and a new Organization object anObject is created with the supplied attributes. anOrganization records a reference to aMember.. The receiver records a reference to anOrganization

Class School

Links
Methods
  • public Boolean hasMember(Name aName, Address anAddress, Email anEmail)

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

Class Organization

Links
  • private Collection<Member> members
Methods
  • Organization(String name, Address address, Member aMember)

  • Postcondition: initialises a new Organization object anOrganization with the given attribute values. A reference to anOrganization is returned

  • public Boolean hasMember(Name aName, Address anAddress, Email anEmail)

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

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** ⚠️