Our enum type ServerState has an underlying int type.
The possible values for ServerState are defined as constants. Since Ada enums automatically assign consecutive values starting from 0, you don’t need to manually assign values as you would in other languages.
By implementing a Stringer equivalent, values of ServerState can be printed out or converted to strings.
If we have a value of type ServerState, we can pass it to the transition function, which will return a new state.
To run the program, save the code in a file, for example, enums.adb, and use GNAT (the GNU Ada compiler) to compile and run it.
This demonstrates basic enum type handling and state transitions in Ada. Ada’s strong type system ensures that the compiler will catch type mismatches, providing compile-time type safety.