Exemple #1
0
        protected override void Interact()
        {
            var kataTask = new ChargeCounterFactory();
            var info     = new SearchInfoBuilder <IChargeCounterAttempts>(Console.In, Console.Out, kataTask);

            info.AskAlgorithm();

            info.AskSingleValue("Enter the amount:");

            info.AskListOfValues("Enter the array of coin denominations:");

            Func <int, int[], int> func = null;

            switch (info.Algo)
            {
            case 1: func = kataTask.GetAlgorithm(info.Algo).Attempt1; break;

            case 2: func = kataTask.GetAlgorithm(info.Algo).Attempt2; break;

            default: throw new ArgumentException("Wrong algorithm index was entered.");
            }
            info.SetResult(func(info.SearchValue, info.List.ToArray()));

            info.ShowResult();
        }
Exemple #2
0
        protected override void Interact()
        {
            var kataTask = new ChopperFactory();
            var info     = new SearchInfoBuilder <IKarateChop>(Console.In, Console.Out, kataTask);

            info.AskAlgorithm();
            info.AskListOfValues("Enter the sorted array of numbers (separated by space):");
            info.AskSingleValue("Enter the value you're looking for:");

            info.SetResult(kataTask.GetAlgorithm(info.Algo).Chop(info.SearchValue, info.List));

            info.ShowResult();
        }