예제 #1
0
 private void SendCoinToReturn(string coinToSend)
 {
     _coinReturn.ReceiveCoin(new List <string> {
         coinToSend
     });
     _timesSendCoinToReturnWasCalled++;
 }
예제 #2
0
        public void MakeChange(int changeNeeded)
        {
            bool          bOutOfChange = false;
            List <string> changeToGive = new List <string>();

            AcceptMoney(_coinSlot.GetCoinsInCurrentTransaction());

            while (changeNeeded > 0 && bOutOfChange == false)
            {
                if (changeNeeded - 25 >= 0 && GetListOfCoinsInBank().Contains(_validator.GetQuarterDefinition()))
                {
                    changeToGive.Add("Q");
                    GetListOfCoinsInBank().Remove("Q");
                    changeNeeded -= 25;
                }
                else if (changeNeeded - 10 >= 0 && GetListOfCoinsInBank().Contains(_validator.GetDimeDefinition()))
                {
                    changeToGive.Add("D");
                    GetListOfCoinsInBank().Remove("D");
                    changeNeeded -= 10;
                }
                else if (changeNeeded - 5 >= 0 && GetListOfCoinsInBank().Contains(_validator.GetNickelDefinition()))
                {
                    changeToGive.Add("N");
                    GetListOfCoinsInBank().Remove("N");
                    changeNeeded -= 5;
                }
                else
                {
                    bOutOfChange = true;
                }
            }
            _coinReturn.ReceiveCoin(changeToGive);
        }