... | ... | @@ -16,16 +16,20 @@ Consider a state as a specific position within the life-cycle or behavior of an |
|
|
Assume that your customer wants you to develop an banking machine application called "ATM" which acts similar to general ATMs, which allow to withdraw or deposit cash. The application can be in four different states (Authentication, WithdrawCash, Rejected, or Finished).
|
|
|
The application starts with Authentication, presents a login screen (openLogin), continues by allowing the user to enter a pin, which is checked afterwards (checkPin), and closes the login screen at the end (closeLogin). Depending on the result of the check (correct or incorrect), the number of unsuccessful tries (errorCounter), and the number of maximum tires (maxTries) the machine may change it's state to another state.
|
|
|
|
|
|
Possible results:
|
|
|
- Option 1: incorrect (pin) and errorCounter < maxTries -> try again, no state change.
|
|
|
- Option 2: incorrect (pin) and errorCounter >= maxTries -> authentication failed, change to state Rejected.
|
|
|
- Option 2: incorrect (pin) and errorCounter >= maxTries -> authentication failed, change to state Rejected (abort of the machine).
|
|
|
- Option 3: correct (pin) -> change to state WithdrawCash
|
|
|
|
|
|
During the withdrawal, the user is able to choose between withdraw and deposit. In both cases he has to define an amount. Depending on the choice, either the specified amountis added to the account or, if the amount does not exceed the balance, substracted from the account. Afterwards the user is able to finish the transaction (abort of the machine).
|
|
|
|
|
|
## An Example Class Diagram for the given Scenario
|
|
|
The following figure shows an example UML state machine diagram, which reflects the requirements mentioned in [Example Scenario](#example-scenario):
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
### Explanation
|
|
|
We model the states at first.
|
|
|
We model the states at first. ...
|
|
|
|
|
|
Additionally, there are two special states (start - circle completely filled in black, stop - white circle with a black circle in the middle), which are used as an entry and exit for the overall machine. |
|
|
\ No newline at end of file |