public abstract class Matrix { //Data - number of rows and columns protected int n; // number of rows protected int m; // number of columns //Abstract methods public abstract double elementAt(int i,int j); public abstract double setElementAt(int i,int j,double value); protected abstract Matrix create(int rows,int cols); //Protected method protected int f(int i,int j) { if (i<1 || i>n || j<1 || j>m) throw new IndexOutOfBoundsException("Incorrect indexes!"); return -1; } //Public methods public int getRows(){ return n; } public int getColumns(){ return m; } public Matrix add(Matrix B) { Matrix A = this; if (B.n != A.n || B.m != A.m) throw new RuntimeException("Illegal matrix dimensions!"); Matrix C = create(n,m); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) C.setElementAt(i,j,A.elementAt(i,j) + B.elementAt(i,j)); return C; } public Matrix mult(Matrix B) { System.out.println("Not implemented!"); return null; } public Matrix mult(double value) { System.out.println("Not implemented!"); return null; } public Matrix transpose() { System.out.println("Not implemented!"); return null; } public boolean equals(Object obj) { Matrix B=(Matrix)obj; System.out.println("Not implemented!"); return false; } }