Les types énumérés – vidéo d’explication
Le code final montré au début de la vidéo
public class EnumStart { enum State{ OPEN, CLOSED, BROKEN }; public static void main(String[] args) { State theDoor = State.CLOSED; System.out.println("The door is " + theDoor); switch (theDoor) { case OPEN: break; case CLOSED: System.out.println("Would you like to break it ? "); if(Input.readChar() == 'y') { theDoor = State.BROKEN; } break; case BROKEN: break; default: System.out.println("Invalid state"); break; } System.out.println("The door is " + theDoor); } }