Условия такие:
Кола стоит 1,5 Евро (reqCoka)
Энергетик 2 евро. (reqEnergy)
Напитки можно выбирать только когда уже внес деньги
Автомат принимает только 50 центов (inp50), 1 Евро (inp100 ) и 2 Евро (inp200)
Сдачу не выдает
После 2 евро деньги больше не принимает.
Вот такую подсказку нам оставили:
def next_state(state, inp):
“”“Calculate the successor state for a given state and input.
Args:
state (int): a natural number, representing the automaton's current state
inp (string): a string representing the automaton's input
Returns:
int: a natural number, representing the automaton's successor state
”“”
pass # TODO: replace by your implementation
def output(state):
“”“Calculate the output in a given state.
Args:
state (int): a natural number, representing the automaton's current state
Returns:
string: the output of the automaton
”“”
pass # TODO: replace by your implementation
def automaton():
“”“Main loop of the automaton.”“”
state = 0
while True:
state = next_state(state, input('> ‘))
print(output(state))
if __name__ == ’__main__':
automaton()
Надо, чтобы на выходе было так :
> inp50
50ct
> inp100
150ct
> inp100
250ct
> inp50
250ct
> reqCoke
COKE
> inp50
150ct
Спасибо