Пример #1
0
        public bool AreAllAmountsValid()
        {
            string[] lines  = System.IO.File.ReadAllLines(_filePath);
            bool     result = true;

            for (int i = 1; i < lines.Length; i++)
            {
                var array = lines[i].Split(' ');

                for (int j = 1; j < array.Length; j++)
                {
                    if (IsValueNumeric.IsNumeric(array[j]))
                    {
                        if (int.Parse(array[j]) < (int)AmountOfEachOrder.Minimum || int.Parse(array[j]) > (int)AmountOfEachOrder.Maximum)
                        {
                            result = false;
                            break;
                        }
                    }
                    else
                    {
                        result = false;
                        break;
                    }
                }
            }
            return(result);
        }
Пример #2
0
        public bool IsNumberOfDailyOrdersValid()
        {
            string[] lines  = System.IO.File.ReadAllLines(_filePath);
            bool     result = true;

            for (int i = 1; i < lines.Length; i++)
            {
                var    array   = lines[i].Split(' ');
                string column1 = array[0];
                if (IsValueNumeric.IsNumeric(column1))
                {
                    if (int.Parse(column1) < (int)NumberOfDailyOrders.Minimum || int.Parse(column1) > (int)NumberOfDailyOrders.Maximum)
                    {
                        result = false;
                        break;
                    }
                }
                else
                {
                    result = false;
                    break;
                }
            }
            return(result);
        }
Пример #3
0
        /*
         * Business logic for calculating sales campaign prize
         *        •	Every order that is placed is automatically entered into the draw
         *        •	At the end of every day, two orders are selected from all those entered into the draw
         *        •	Firstly, the order for the largest amount is selected
         *        •	Secondly, the order for the smallest amount is selected
         *        •	The customer who placed the largest order receives prize money equal to the amount of their order less the amount of the smallest order
         *        •	The two selected orders are removed from the draw
         *        •	All other orders remain eligible for draws on subsequent days
         */

        public static int TotalPrizeMoneyGivenOutFromStandardInput()
        {
            //Console.Write("Please enter the number of days for the campaign: ");
            string input = Console.ReadLine();                   // Get input fromthe user as a string

            while (!IsValueNumeric.IsNumeric(input))             //Check that the input is numeric
            {
                Console.Write("Only numbers are accepted, try again: ");
                input = Console.ReadLine();
            }

            //Check that the number of days is valid
            while (int.Parse(input) < (int)NumberOfDays.MinimumNumberOfDays || int.Parse(input) > (int)NumberOfDays.MaximumNumberOfDays)                   //Check that the input is numeric
            {
                Console.Write("Valid umbers are between {0} and {1} inclusive: ", (int)NumberOfDays.MinimumNumberOfDays, (int)NumberOfDays.MaximumNumberOfDays);
                input = Console.ReadLine();
            }

            int numOfDays = int.Parse(input);                 //store the number of days in rder to control the prompts

            var lines = new List <string>();                  //Store all lines entered by the user

            for (int i = 0; i < numOfDays; i++)
            {
                //Console.Write("Please enter the data for day {0}: ", i + 1);
                lines.Add(Console.ReadLine());

                //more checks need to ensure that input is valid ...caling functions in the IsInoutValid class
            }

            return(CalculateTotalPrizeMoneyGivenOut(lines, 0));                  //return total prize money given out
        }
Пример #4
0
 public bool IsFirstLineOfFileANumber()
 {
     return(IsValueNumeric.IsNumeric(FirstLineOfFile()));
 }