Skip to content

Implementation Role Feature 3

Max Leuthäuser edited this page Oct 16, 2015 · 4 revisions

Title

Objects may play different roles simultaneously

Description

Because a role is a type (and implemented as classes in SCROLL) it amounts to the multiple classification of objects.

Implementation

Consider e.g. the robot example:

val myRobot = Robot("Pete") play ServiceRole() play NavigationRole() play ObservingEnvironmentRole() play DriveableRole()

By simply calling the play-method multiple times you can attach as many roles as you want.

Additional hints

The return type of the play-method is a generic Player instance, typed with your core- (player) object. In this example Robot, hence Player[Robot]. If you want to get back the original instance of the core object please use playing.

Clone this wiki locally