Exemplo n.º 1
0
        public IMatrixElement GetElementAbove(IMatrixLine line, IMatrixElement element)
        {
            if (!HasLineAbove(MatrixInstance.IndexOf(line)))
            {
                return(GetEmptyElement());
            }

            int         indexOfElement = line.Line.IndexOf(element);
            IMatrixLine lineAbove      = MatrixInstance[MatrixInstance.IndexOf(line) - 1];

            return(lineAbove.GetElementAtIndex(indexOfElement));
        }
Exemplo n.º 2
0
        public IMatrixElement GetElementBelow(IMatrixLine line, IMatrixElement element)
        {
            if (!HasLineBelow(MatrixInstance.IndexOf(line)))
            {
                return(GetEmptyElement());
            }

            int         indexOfElement = line.Line.IndexOf(element);
            IMatrixLine lineBelow      = MatrixInstance[MatrixInstance.IndexOf(line) + 1];

            return(lineBelow.GetElementAtIndex(indexOfElement));
        }
Exemplo n.º 3
0
        public IMatrix InitializeMatrix(IMatrix matrix, int size)
        {
            if (size == 0 || size == 1 || size < 0)
            {
                throw new InvalidOrNotExistentMatrixSizeException(Message: Locales.Strings.InvalidMatrixSize);
            }

            List <IMatrixLine> lineList = new List <IMatrixLine>();

            for (int i = 0; i < size; i++)
            {
                List <IMatrixElement> elementList = new List <IMatrixElement>();
                for (int j = 0; j < size; j++)
                {
                    IMatrixElement matrixElement;
                    matrixElement = CreateMatrixElement(MatrixElementType.Available, i, j);
                    elementList.Add(matrixElement);
                }
                IMatrixLine matrixLine = CreateMatrixLine(elementList);
                lineList.Add(matrixLine);
            }
            matrix = CreateMatrix(lineList);
            return(matrix);
        }