READY is the ticket machine state in which the machine is prepared to accept a customer’s credit card. It is the initial state and handles all four actions, including actions that do not cause a transition. section 13.1.2 section 13.1
READY responds to customer actions as follows:
- Insert a card: mark it inserted, set validity to unknown, and transition to VALIDATING when no card is present. section 13.1.2
READY as a State object
After refactoring, class READY encapsulates these behaviors instead of sharing a switch statement with every other state. Its action methods return the next State object; ordinary READY actions return this, while card insertion returns states.VALIDATING_state. section 13.1.3
Figure 13.1 A UML state diagram showing the four states and the state transitions of an automatic ticket machine. The machine keeps track of the number of tickets it has, whether there is a credit card inserted, and the validity status of the card. Customer and machine actions (numbered; e.g., 1: insert card) or certain conditions (in square brackets; e.g., [card invalid]) can cause transitions from one state to another. This figure only shows the actions that cause transitions.
The state diagram shows READY’s position among the ticket machine’s four named states and its transition conditions. section 13.1
