/// <summary>
        /// A private method to get the allowable pairings from the input lines
        /// </summary>
        /// <param name="input"></param> a string[ ] whose elements are the lines from the input file
        /// <param name="tables"></param> an int giving the number of tables
        /// <returns></returns>return a Pairing[ ] containing the pairings from the input.
        private static Pairing[]  GetAllowableParirings(string[] input, int tables)
        {
            Pairing[] pairs = new Pairing[input.Length];
            string[]  line;
            int       limit = tables * 2;

            for (int i = 0; i < input.Length; i++) // part where differ array by 1;
            {
                line = input[i].Split(',');
                if (line[0] == line[1])
                {
                    throw new IOException("Line " + i + 2 + " First player and Second player are same.");
                }
                else
                {
                    pairs[i] = new Pairing(ValiddateElement(line[0], limit, i + 2, "First Player"), ValiddateElement(line[1], limit, i + 2, "Second Player"), ValiddateElement(line[2], tables, i + 2, "Table"));
                }
            }
            return(pairs);
        }
        /// <summary>
        /// A private method to find a matching
        /// </summary>
        /// <param name="input"></param>a Pairing[ ] containing all allowable pairings
        /// <param name="tables"></param> an int giving the number of tables
        /// <returns></returns>return a Pairing[ ] containing the pairings in a matching
        private static Pairing[] GetMatching(Pairing[] input, int tables)
        {
            //A bool[ ] whose length is the number of players
            bool[] playerInPosition = new bool[tables * 2];
            //A Pairing[ ] whose length is the number of tables
            Pairing[] tableInPosition = new Pairing[tables];
            //A Stack<int> containing indices into the array of allowable pairings.
            Stack <int> backTracking = new Stack <int>();
            //An int giving the current location in the array of allowable pairings.
            int currentLocation = 0;

            while (backTracking.Count != 0 || input.Length > currentLocation)
            {
                if (backTracking.Count == tables)
                {
                    return(tableInPosition);
                }
                else if (currentLocation >= input.Length)
                {
                    currentLocation = backTracking.Pop();
                    Pairing temp = input[currentLocation];
                    playerInPosition[temp.FirstPlayer]  = false;
                    playerInPosition[temp.SecondPlayer] = false;
                    tableInPosition[temp.Table]         = null;
                }
                else if (playerInPosition[input[currentLocation].FirstPlayer] == false && playerInPosition[input[currentLocation].SecondPlayer] == false && tableInPosition[input[currentLocation].Table] == null)
                {
                    playerInPosition[input[currentLocation].FirstPlayer]  = true;
                    playerInPosition[input[currentLocation].SecondPlayer] = true;
                    //if(tableInPosition[currentLocation]==null)
                    tableInPosition[input[currentLocation].Table] = input[currentLocation];
                    backTracking.Push(currentLocation);
                }
                currentLocation++;
            }


            //if no matching found return null instead
            return(null);
        }