← Questions
Payment command parser and state machine
0
I was asked this
No reports yet. Sign in to say where you were asked it.
Build the parser and the object-oriented state machine behind a payment command interface. Every command line has the same fixed number of positions, with empty strings in the unused ones: CREATE id payer payee amount, then APPROVE, CAPTURE and CANCEL, which name an existing payment and an amount. Parse each line, apply it to its payment, reject transitions the payment's current state does not allow, and structure the classes so new commands and states are easy to add.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding
