state pattern rejecting pin getting transaction selection set of states for every part of every transaction finalizing transaction returning card printing slip dispensing slip specific system and user actions will cause the atm to move from one state to the next inserting card into the machine will cause the machine to transition from the waiting state to the accepting_card stateand so on once you have drawn up complete state diagram for systemyou will have fairly complete picture of what the system should be doing every step of the way you will also have clarity on how your system should be moving from one step to another all that remains is to translate your state diagram into code naive way to translate the diagram into runnable code is to create an object that represents the state machine the object will have an attribute for its statewhich will determine how it reacts to input if we were to code up the first example of the game characterit would look something like this window systems have issues with cursesbut that can be fixed by installing cygwinwhich gives you linux-like terminal that works well with the curses library curses to download cygwinhead to the main website at download the current dll version that matches your machine if you find you have to set up python againjust follow the steps under the linux section of the installation guide from the beginning of this book import time import curses def main()win curses initscr(curses noecho(win addstr( "press the keys to initiate actions"win addstr( "press to exit"