GeometryClassLibrary.MatricesMatrix.TotalRows C# (CSharp) Method

TotalRows() public method

Returns the total number of rows required to contain all of the rows from the inner matrices
public TotalRows ( ) : int
return int
        public int TotalRows()
        {
            int totalRows = 0;

            for (int rowIndex = 0; rowIndex < this.NumberOfRows; rowIndex++)
            {
                int maxRowHeight = 0;
                for (int columnIndex = 0; columnIndex < this.NumberOfColumns; columnIndex++)
                {
                    int rowHeight = this.GetRowHeight(rowIndex);
                    if (rowHeight > maxRowHeight)
                    {
                        maxRowHeight = rowHeight;
                    }
                }
                totalRows += maxRowHeight;
            }

            return totalRows;

        }

Usage Example

コード例 #1
0
        public void TotalRowsTest_EqualRowDistances()
        {
            Matrix m1 = new Matrix(2);
            Matrix m2 = new Matrix(2, 3);
            Matrix m3 = new Matrix(2);
            Matrix m4 = new Matrix(2, 3);
            
            MatricesMatrix testMatricesMatrix = new MatricesMatrix(2, 2);

            testMatricesMatrix.SetElement(0, 0, m1);
            testMatricesMatrix.SetElement(0, 1, m2);
            testMatricesMatrix.SetElement(1, 0, m3);
            testMatricesMatrix.SetElement(1, 1, m4);

            int expectedResult = 4;

            int actualResult = testMatricesMatrix.TotalRows();

            (actualResult == expectedResult).Should().BeTrue();

        }