Finite state machine: Difference between revisions

Include the state in the prompt
m (→‎{{header|ALGOL 68}}: Fixed prompt)
(Include the state in the prompt)
 
Line 107:
INT state := initial state;
WHILE state /= exit state DO
print( ( "Ready: " ) );
BOOL found := FALSE;
FOR s pos FROM LWB states TO UPB states WHILE NOT found DO
Line 146 ⟶ 145:
 
run fsm( ( ( ready
, INT: IF "Q" = get code( "Ready : Enter D to deposit, Q to Quit", "DQ" )
THEN exit
ELSE waiting
Line 152 ⟶ 151:
)
, ( waiting
, INT: IF "S" = get code( "Waiting : Enter S to Select, R to Refund", "SR" )
THEN dispense
ELSE refunding
Line 158 ⟶ 157:
)
, ( dispense
, INT: BEGIN get code( "Dispensing: Remove your product and Enter R", "R" ); ready END
ready
print( ( "Ready: " ) ); END
)
, ( refunding
Line 174 ⟶ 175:
{{out}}
<pre>
Ready : Enter D to deposit, Q to Quit: d
ReadyWaiting : Enter S to Select, R to Refund: s
ReadyDispensing: Remove your product and Enter R: r
Ready : Enter D to deposit, Q to Quit: d
ReadyWaiting : Enter S to Select, R to Refund: r
Ready: Refunding
Ready : Enter D to deposit, Q to Quit: q
</pre>
 
3,022

edits