'ATM with Chain of Responsiblility

Hey so i want to build a simple ATM via the chain of responsiblility,

So lets say someone enters 982.55€ I need to go through the chain in the following order: 500€,200€,100€,50€,20€,10€,5€,2€,1€,50ct,20ct,10ct,5ct,2ct,1ct

982.55 / 500 = 1.97 -> so i want to cash out one 500€ bill and proceed the check with 482.55 and the 200€ bill.

482.55 / 200 = 2.41 -> cash out two 200€ bills

82.55 / 100 = 0.83 -> no cashout

82.55 / 50 = 1.65 -> cash out one 50€ bill and so on

How can i tell the chain that it should start at 500€,200€,100€ and so on, otherwise the cash out wouldnt work properly

tyvm



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source