The possible values for ServerState are defined as constants. The enum values are automatically generated and assigned the values 0, 1, 2, and so on.
By implementing the toString() method, values of ServerState can be printed out or converted to strings. This can get cumbersome if there are many possible values. In such cases, reflection or auxiliary tools can be used to automate the process.
If we have a value of type Int, we cannot pass it to transition - the compiler will complain about type mismatch. This provides some degree of compile-time type safety for enums.
transition emulates a state transition for a server; it takes the existing state and returns a new state.
To run the program, compile the code using kotlinc and then use kotlin to execute it.