Finite state machine: Difference between revisions
→{{header|FreeBASIC}}
(Finite state machine en FreeBASIC) |
|||
Line 552:
=={{header|FreeBASIC}}==
{{trans|Phix}}
<lang freebasic>
READY
WAITING
DISPENSE
REFUND
QUIT
End Enum '-- (or just use strings if you prefer)
Dim As states state = READY
Dim As String KBD = " "
Do
Print KBD
Select Case state
Case
Print "Machine is READY. (D)eposit or (Q)uit : ";
Do
Do: KBD = Ucase(Inkey): Loop While KBD = ""
If KBD = "D" Then state =
If KBD = "Q" Then state =
Loop
Case
Print "(S)elect product or choose to (R)efund : ";
Do
Do: KBD = Ucase(Inkey): Loop While KBD = ""
If KBD = "S" Then state =
If KBD = "R" Then state =
Loop
Case
Print "Dispensing product... ";
Print "Please (C)ollect product. : ";
Do
Do: KBD = Ucase(Inkey): Loop While KBD = ""
If KBD = "C" Then state =
Loop
Case
Print "Please collect refund."
state =
KBD = " "
Case
Print !"Thank you, shuttingwn now.\n"
Exit Do
Line 595 ⟶ 604:
Igual que la entrada de Phix.
</pre>
=={{header|Go}}==
|