A state is defined very broadly in UML as:
A State models a situation in the execution of a StateMachine Behavior
during which some invariant condition holds.
To make it more practical, imagine that a state corresponds to the machine waiting for some things to happen, and when they happen the machine may change its state.
Here there are clearly several different states belonging to your state machine:
- There are states about what to do with coins: it starts with
Accepting coins until it will
Not accepting coins anymore, at least temporarily.
- There are states about money: At the beginning, there's
No credit. At every insertion of a coin, the credit increases. When the first coin is inserted, the machine reaches a state
- There are states about product selection: as soon as there is credit, we have
Cancelation selectable. Depending on the credit available, different products may become selectable:
Coke and Pepsi selectable,
Coke and Pepsi and Soda selectable. Then it's about
- Then there are states about the outcome:
Product delivered which would automatically decrease the money available.
Cash returned which means that we start a new.
But I'll leave you some (home)work: you now need to see which states are mutually exclusive, and which can happen together and merge those in a composite state.
You may then add the state transitions. Some transitions are automatic (e.g. product delivered-> cash returned) . Some transition are event driven (e.g. coin inserted).
Now it's up to you to assemble the pieces of the puzzle. Good luck