Enumerated

Abstract superclass for enumerated quantities.

Contents

Description

Enumerated is the superclass of classes representing enumerated quantities. Each subclass of Enumerated allows only instances predefined by enumeration. For more details about enumeration, see Enumerations.

Enumerated supports conversion of its instance into a string by char(), and into an integer by int().

Each concrete subclass of Enumerated allows comparison between its instances, i.e., supports relational operators <, <=, ==, >=, and >. Also, the result consistent with this comparison is returned by sort() on a vector of these instances.

Concrete Subclasses

Methods (static)

Below, Enumerated must be replaced by a concrete subclass.

Methods (public)

Below, enumerated is an instance of a concrete subclass of Enumerated.

Example

Below, the methods of Enumerated are demonstrated using a concrete subclass Axis.

% Test conversion to integers and strings.
fprintf('Total # of Axis objects: %d\n', Axis.count);
for w = Axis.elems
    fprintf('Name of Axis object %d: %s\n', int(w), char(w));
end
% Test sort().
unsorted = [Axis.z, Axis.x, Axis.y];
fprintf('\nBefore sort: ');
for w = unsorted
    fprintf('%s  ', char(w));
end
fprintf('\nAfter sort: ');
sorted = sort(unsorted);
for w = sorted
    fprintf('%s  ', char(w));
end
fprintf('\n');