// ITI1120 A 4
// Names: Daniel Amyot, 1234567
//        Diana Inkpen, 7654321
// Library class for matrices

class MatriceLib
{
  // METHOD display: Displays the content of a matrix
  // GIVENS: mat, a matrix of integers
  // RESULT: None
  // ASSUMPTIONS: the matrix is not empty
  public static void display (int[][] mat)
  {
    // DECLARATION OF VARIABLES / DATA DICTIONNARY
    int noRows, noCols;  // INTERMEDIATES: size of mat
    int r, c;            // INTERMEDIATES: Index for traversing the matrix
    
    // BODY OF THE ALGORITHM

    noRows = mat.length;
    noCols = mat[0].length;
    
    r = 0;
    while (r < noRows)
    {
      c = 0;
      while (c < noCols)
      {
        System.out.print(mat[r][c] + " ");
        c = c + 1;
      }
      System.out.println(); // go to the next row
      r = r + 1;
    }
        
    // RETURN RESULT: NONE
  }
  
  
  // METHOD compare: test the equality of two matrices
  // GIVENS: mat1 and mat2: two matrices of integers
  // RESULT: true is their content is equal 
  // ASSUMPTIONS: the matrices are not empty
  public static boolean compare (int[][] mat1, int[][] mat2)
  {
    // DECLARATION OF VARIABLES / DATA DICTIONNARY
    int noRows1, noCols1;  // INTERMEDIATES: size of mat1
    int r, c;                // INTERMEDIATES: Index for traversing the matrices
    boolean equals;          // RESULT: true if mat1 and mat2 are equal

    // BODY OF THE ALGORITHM


    noRows1 = mat1.length;
    noCols1 = mat1[0].length;
    
    // do they have the same size?
    equals = (noRows1 == mat2.length && noCols1 == mat2[0].length);
    
    r = 0;
    while (r < noRows1 && equals)
    {
      c = 0;
      while (c < noCols1 && equals)
      {
        equals = (mat1[r][c] == mat2[r][c]);
        c = c + 1;
      }
      r = r + 1;
    }

    // RETURN RESULT
    return equals;
  }
  

  // Q1: TO COMPLETE!
  // METHOD rotation: rotates a square matrix clockwise 
  // Attention: It is different from the transposition of a matrix!
  // GIVENS: a matrix of integers
  // RESULT: a new matrix of integers 
  // ASSUMPTIONS: the matrix is square and has size > 0
  public static int[][] rotation (int[][] matrix)
  {
    // DECLARATION OF VARIABLES / DATA DICTIONNARY

    // BODY OF THE ALGORITHM



    // RETURN RESULT    
    return matrix; // TO REPLACE!
  }
  
}
