[Previous]  [Next] 
|
User Manual [Previous]  [Next] interface DefinitionAn interface defines a list of abstract methods that are to be implemented in one or more classes. An interface can be composed of the following elements:
To implement an interface in a class, or to create subinterfaces, use an isA clause. Umple also supports a feature called traits, that has some similarities to interfaces. However, traits concrete methods, attributes and state machines to also be contained in them. In the following example, RegisterCapable is an interface that defines a single abstract method registerForCourse(). This is implemented concretely by CorporateClient and IndividualStudent. Exampleinterface RegisterCapable { depend school.util.*; boolean registerForCourse(Course aCourse); } class Person { name; } class CorporateClient { isA RegisterCapable; boolean registerForCourse(Course aCourse) { // write code here } 0..1 <- * Person employees; } class IndividualStudent { isA Person, RegisterCapable; boolean registerForCourse(Course aCourse) { // write code here } } class Course { name; description; * -- * Person registrants; } Load the above code into UmpleOnline Syntax// An Interface can only contain method. See interfaceDefinition interfaceDefinition : interface [name] { [[depend]]* [[interfaceBody]] } // Interfaces: Note that if the format of an abstractMethodDeclaration is not // followed, then the body will extraCode and passed to the base language // See user manual page interfaceDefinition interfaceBody- : [[interfaceMemberDeclaration]]* interfaceMemberDeclaration : [[comment]]  | [[reqImplementation]]  | [[constantDeclaration]]  | [[constantDeclarationDeprecated]]  | [[abstractMethodDeclaration]]  | [[position]]  | [[displayColor]]  | [[isA]]  | [[interfaceTest]]  | [[distributableInterface]]  | [[exception]]  | [[extraCode]] |