Question: public class Matrix { private int[][] matrix; /** * default constructor -- * Creates an matrix that has 2 rows and 2 columns */ public

public class Matrix {

private int[][] matrix;

/** * default constructor -- * Creates an matrix that has 2 rows and 2 columns */ public Matrix(int [][] m) { boolean valid = true; for(int r = 1; r < m.length && valid; r++) { if(m[r].length != m[0].length) valid = false; } if(valid) matrix = m; else matrix = null;

} public String toString() { String str = ""; for (int i = 0 ; i

} public Matrix sub(Matrix om) { { Matrix newMatrix = null; if(om.matrix[0].length == this.matrix[0].length) { newMatrix.matrix = new int[matrix.length][matrix.length]; for (int i = 0; i < om.matrix[0].length; i++) for (int j = 0; j < om.matrix[0].length; j++) newMatrix.matrix[i][j] = om.matrix[i][j] - this.matrix[i][j]; } return newMatrix;

} } public Matrix multi(Matrix om) { return null; } public Matrix scalar(Matrix om) { return null; } public boolean equal(Matrix om) { return false; } public Matrix transpose(Matrix om) { return null; }

//sub, multi, scalar, equal, transpose methods need editing but not sure how to fix

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!