Esempio n. 1
0
        public WordByWordField(string letters, IWordProvider wordProvider) //TODO: refactor
        {
            if (wordProvider == null)
            {
                wordProvider = new AnyWordProvider();
            }

            _wordProvider = wordProvider;

            var size = (int)Math.Sqrt(letters.Length);

            string[] lines = new string[size];
            for (int i = 0; i < size; i++)
            {
                lines[i] = letters.Substring(i * size, size);
            }

            _field = new char[size, size];
            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    _field[i, j] = lines[i][j];
                }
            }
        }
Esempio n. 2
0
        public WordByWordField(string[] lines, IWordProvider wordProvider)
        {
            if (lines == null || lines.Length < 2 || lines.Length != lines[0].Length)
            {
                throw new ArgumentException();
            }

            if (wordProvider == null)
            {
                wordProvider = new AnyWordProvider();
            }

            _wordProvider = wordProvider;

            int size = lines.Length;

            _field = new char[size, size];
            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    _field[i, j] = lines[i][j];
                }
            }
        }