In one of my classes we are learning about circuits. For homework, we have to create a finite state machine for a vending machine using an SR flip-flop. The machine can either take a nickel, dime, or nothing until it gets to at least 15 cents, so it has 4 states (0, 5, 10, and 15 cents). Once the machine receives 15 cents, it dispenses its product. Once in this state, if nothing is deposited it goes to the 0 state; if a nickel is deposited it goes to the 5 cent state; if a dime is deposited, it does to the 10 cent state. 

The truth table that I came up with is:

Present|Inputs| Next  |        | SR Flip Flop
       |      |       | Output |
Q1  Q0 |D   N |P1   P0|        | S1 R1 S0 R0
_______|______|_______|________|_____________
0   0  | 0  0 | 0   0 |   0    | 0  X 0 X
0   0  | 0  1 | 0   1 |   0    | 0  X 1 0
0   0  | 1  0 | 1   0 |   0    | 1  0 0 X
0   0  | 1  1 | X   X |   X    | X  X X X
_______|______|_______|________|_____________
0   1  | 0  0 | 0   1 |   0    | 0  X X 0
0   1  | 0  1 | 1   0 |   0    | 1  0 0 1
0   1  | 1  0 | 1   1 |   0    | 1  0 X 0
0   1  | 1  1 | X   X |   X    | X  X X X
_______|______|_______|________|_____________
1   0  | 0  0 | 1   0 |   0    | X  0 0 X
1   0  | 0  1 | 1   1 |   0    | X  0 1 0
1   0  | 1  0 | 1   1 |   0    | X  0 1 0
1   0  | 1  1 | X   X |   X    | X  X X X
_______|______|_______|________|_____________
1   1  | 0  0 | 0   0 |   1    | 0  1 0 1
1   1  | 0  1 | 0   1 |   1    | 0  1 X 0
1   1  | 1  0 | 1   0 |   1    | X  0 0 1
1   1  | 1  1 | X   X |   X    | X  X X X


Based on this truth table [and the k-maps I made from it], I created the following logic gates:


My question is, where exactly does the "reset" happen? For example, if I am in the 15 cent state and deposit a nickel, how does it go to the 5 cent stage? Do I have to make the output from "open" loop around? Sorry for such a novice question, I hope that made sense!

Edit: The first two columns are for the present state of the machine, i.e., how much you have deposited so far. So Q0 Q1 = 00 represents the first state (0 cents), Q0 Q1 = 01 represents the second state (5 cents), etc. The next two columns represent adding a nickel or dime. If you are in the state 00 and and 01, you should move to state 01. Since you cannot deposit a nickel and dime simultaneously, we don't care about the the input 11. If you are in state 10 and add 10, you go to state 11 (and don't get any change back!).


Question: Service Layer Pattern - Could we avoid the service layer on a specific case?
Answer: As mentioned in the link you posted, the service layer defines an "interface" for clients by encapsulating the (complex) business logic and centralizing the control of transaction involving several resources. The service layer is not only used when you need to "share" services, it just makes it easier. But even with a single consumer, centralizing the control of transaction makes sense.