Simple example of Finite-State Machines on Automated Teller Machine of some Bank
Written on Java with Polymorphism form
Inspired by course of Program Principles 2 by @Beisenbek
Return to the idea of FSM after two years :)
All states are singleton classes with access to database and machine data. Have .next() method for each state. Only some states are final.
- s - request PIN
- h - session finished
- e - session finished with error
- q0 - choose option in main menu
- q1 - making transaction
- q2 - enter sum to withdraw
- q3 - output account cash
- q4 - enter cash to replenish
- q5 - enter sum and account to transfer
- q6 - enter a pin to change
- p0 - wrong PIN
- p1 - correct PIN
- m0 - returning to menu
- m1 - choosing invalid option at menu
- e0 - finishing session
- e1 - system error
- z0 - choosing to withdraw cash
- z1 - asserting withdrawing
- z2 - checking account
- z3 - choosing to replenish cash
- z4 - asserting replenish
- z5 - enter sum again
- z6 - choosing to transfer sum
- z7 - asserting transfer
- z8 - enter account again
- z9 - choosing change pin
- z10 - enter a pin again (wrong pin)