uOttawaUniversity of Ottawa - Canadas University
list of dots

Umple User Manual    [Previous]   [Next]   

Loading

Traits and Umple Mixins

In the same way Umple supports mixins to compose classes, traits can also be composed in this way. This means that a trait can be defined in several places or files and when they are used by clients, all elements defined in those separate places will be applied to clients.

The example 1 depicts two definitions for trait T1 (lines 4 and 8). Class C1 uses trait T1 and implement the required method method1() and also obtains two provided methods method2() and method3().

Example

/*
	Example 1: showing how traits are combined with Umple mixins.
*/
trait T1{
  void method1();
  void method2(){/*impl… */ }
}
trait T1{
  void method3(){/*impl… */ }
}
class C1{
  isA T1;
  void method1(){/*impl… */ }    
}

      

Load the above code into UmpleOnline