Exemple #1
0
        private static void UpdateChangeOption(ChangeOptionList possibleChangeOptions, int targetValue, int coin, ChangeOption existingChangeOption)
        {
            var newCoinList = CreateNewCoinList(coin, existingChangeOption);

            if (!possibleChangeOptions.ChangeOptionExistsForTargetValue(targetValue))
            {
                possibleChangeOptions.AddChangeOption(targetValue, newCoinList);
            }
            else
            {
                possibleChangeOptions.GetChangeOption(targetValue).SetChangeCoins(newCoinList);
            }
        }
Exemple #2
0
        private static ChangeOption GetPossibleChangeOptionWhenCoinSubtractedFromSubTarget(ChangeOptionList possibleChangeOptions, int coin, int subtarget)
        {
            int targetAfterCoinStubtracted = subtarget - coin;

            return(possibleChangeOptions.GetChangeOption(targetAfterCoinStubtracted));
        }
Exemple #3
0
 private static bool ExistingChangeOptionShouldBeUpdated(ChangeOptionList existingChangeOptions, int subtarget, ChangeOption newChangeOption)
 {
     return(newChangeOption != null &&
            (!existingChangeOptions.ChangeOptionExistsForTargetValue(subtarget) || NewChangeOptionIsShorter(existingChangeOptions.GetChangeOption(subtarget), newChangeOption)));
 }