One embodiment of the present invention provides a system that facilitates
use of an object-oriented enumerated type within a computer program.
During operation, the system receives source code for the computer
program, wherein the source code contains a declaration for an enumerated
type. This declaration specifies a fixed number of enumeration constants
that comprise the enumerated type. Next, the system defines the
enumerated type using a class defined within an object-oriented
programming language, wherein the class includes a constant for each
enumeration constant specified in the declaration. If the declaration
additionally contains one or more method declarations, these methods are
present on the defined class.