Example #1
0
        /// <summary >
        /// Sets the neighbour option, Which updates three variables: neighbourType, Order and centreCount.
        /// Validation is done inside this method because it is handled diffrently to other options.
        /// </ summary >
        /// <param name =" args " >String arguments that initialise the Game of Life settings</ param >
        /// /// <param name =" pos " >The position of the --neighbour option within the args array</ param >
        private void readNeighbour(int pos, string[] args)
        {
            //moore or vonNeumann
            if (args[pos + 1] == "moore")
            {
                neighbourType = false;
            }
            else if (args[pos + 1] == "vonNeumann")
            {
                neighbourType = true;
            }
            else
            {
                validate.invalid(args[pos + 1] + " is an invalid option");
            }

            if (validate.order(int.Parse(args[pos + 2])))
            {
                order = int.Parse(args[pos + 2]);                                          //neighbourhood size
            }
            //count the centre?
            if (args[pos + 3] == "true")
            {
                centreCount = true;
            }
            else if (args[pos + 3] == "false")
            {
                centreCount = false;
            }
            else
            {
                validate.invalid(args[pos + 3] + " is an invalid option");
            }
        }