Skip to content

Implementation Role Feature 8

Max Leuthäuser edited this page Nov 18, 2021 · 5 revisions

Title

Roles can play roles

Description

Consider the example where an employee (role of a person) can be a project leader, which is a role of the employee and now indirectly of the person itself.

Implementation

Consider the banking example:

val stan  = Person("Stan")
val brian = Person("Brian")

val accForStan  = new Account(10)
val accForBrian = new Account(0)

val _ = new Bank {
  val ca = new CheckingsAccount()
  val sa = new SavingsAccount()

  roleGroups.checked {
    accForStan play ca
    accForBrian play sa
  }
  stan play new Customer()
  brian play new Customer()

  // ...
}

Both accounts (core objects/players) play the CheckingsAccount role, which itself plays the Source/Target role respectively.

Additional hints

None.

Clone this wiki locally