Пример #1
0
        static void RunInputCalculator()
        {
            var inputCalculator = new InputCalculator();

            machineModifier = 0.0m;
            do
            {
                var result = PrintInputMessage("Recipe Time");
                if (decimal.TryParse(result, out decimal value))
                {
                    inputCalculator.RecipeTime = value;
                }
                else
                {
                    Console.WriteLine("Invalid Value");
                }
            } while (inputCalculator.RecipeTime == 0.0m);

            do
            {
                Console.WriteLine("Build Modifier:");
                _inputCalcualtorMenu.Display();
                inputCalculator.MachineModifier = machineModifier;
            } while (inputCalculator.MachineModifier == 0.0m);

            do
            {
                var result = PrintInputMessage("Belt Speed");
                if (int.TryParse(result, out int value))
                {
                    inputCalculator.BeltSpeed = value;
                }
                else
                {
                    Console.WriteLine("Invalid Value");
                }
            } while (inputCalculator.BeltSpeed == 0);

            do
            {
                var result = PrintInputMessage("Input Amount");
                if (int.TryParse(result, out int value))
                {
                    inputCalculator.InputAmount = value;
                }
                else
                {
                    Console.WriteLine("Invalid Value");
                }
            } while (inputCalculator.InputAmount == 0);

            Console.WriteLine($"The number of machines needed is {inputCalculator.CalculateMachinesNeeded()}");

            ReShowMenu();
        }
        public void given_a_belt_speed_of_1800_and_a_recipetime_of_6_seconds_and_an_input_of_10_and_a_modifier_of_1_5_when_calculated_the_result_is_12()
        {
            var inputCalculator = new InputCalculator();

            inputCalculator.InputAmount     = 10;
            inputCalculator.MachineModifier = 1.5m;
            inputCalculator.RecipeTime      = 6;
            inputCalculator.BeltSpeed       = 1800;

            var result = inputCalculator.CalculateMachinesNeeded();

            Assert.IsTrue(result == 12m);
        }