uc 09 - yshehab/SchoolRoomBooking GitHub Wiki

9. Create an account for a permit

Coordinating method

public void createAccount(Permit aPermit)

Object diagram for a typical scenario.

Walk-through for this scenario

Given: The Permit object permit7

  1. Check there is not already an account object associated with permit7
    As the check succeeds:
  2. Create a new variable chargeTotal
  3. Access the collection of Booking objects linked to permit7, which is in this case booking42 and booking 84
    For each of the booking objects accessed in step 2, increment chargeTotal by the value of it_s cost attribute.
  4. Check the value of chargeTotal is greater than 0
    As the check succeeds:
  5. A new Account object, account68 is created with chargeTotal as it_s cost attribute.

Sequence diagram for this scenario

Notes on alternative scenario

  • If aPermit is linked to a charge object throw an exception
  • If totalCharge # 0, throw an exception

Updates to implementation model

Classes

Class Booking

Links
Methods
public BigDecimal getCost()

Post condition: Returns the receiver_s cost

Class Permit

Links

private collection<Booking> bookings

Methods

public void createAccount()

Post condition: a new Account object is created with it_s cost attribute the sum of the cost attributes of all the receivers linked Booking objects
If the receiver has a linked Account object then an exception is thrown.
If the sum of the cost attributes of all the receivers linked Booking objects # 0, then an exception is thrown.

Class LettingCoord

Links

None

Methods

public void createAccount(Permit aPermit)
Post condition: a new Account object is created with it_s cost attribute the sum of the cost attributes of all the Booking objects linked to aPermit.
If the aPermit has a linked Account object then an exception is thrown.
If the sum of the cost attributes of aPermits linked Booking objects # 0, then an exception is thrown.

Navigations

consistsOf from Permit to Booking

Discussion

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