uOttawaUniversity of Ottawa - Canadas University
list of dots

Umple User Manual    [Previous]   [Next]   

Loading

interface Definition

An interface defines a list of methods that are to be implemented in one or more classes. An interface can be composed of the following elements:

Umple currently supports Java, PHP and Ruby as native languages.

To implement an interface in a class, or to create subinterfaces, use an isA clause.

Example

interface 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]]
    | [[constantDeclaration]]
    | [[constantDeclarationDeprecated]]
    | [[abstractMethodDeclaration]]
    | [[position]]
    | [[displayColor]]
    | [[isA]]
    | [[distributableInterface]]
    | [[exception]]
    | [[extraCode]]