next up previous contents index
Next: Array declaration Up: No Title Previous: Defining constraints

   
Arrays

It is possible to declare arrays of components and attributes. An array is a collection of elements all of the same type. Arrays are convenient for handling a collection of components of the same type. Consider, for example, the task of building a panel that consists of many buttons each of which displays ``Hello'' is a different language. The following shows part of a class for such a panel:
    class Hellos {
        component Button hws[10]{
              {text == "Hello"},
              {text == "Bonjour"},
              {text == "Kon Ni Chi Wa"},
              ...
              {text == "Ni Hao"}};
    }
This class has ten buttons, each of which has a different text on it.

Arrays are also convenient for imposing constraints on a group of components, such as global and aggregate constraints. Sometimes, we want to impose constraints on an arbitrary group of components. For this purpose, DJ provides anonymous arrays. An anonymous array is an array that can be constructed by explicitly listing its elements or implicitly by using a set expression.



 

Neng-Fa Zhou
1999-02-16