Advertisement
Atem85

Immutable

Sep 20th, 2014
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1. package nWeb4;
  2.  
  3. /**
  4.  * Created by Артем on 16.09.2014.
  5.  */
  6. public final class Immutable extends MatrixImpl implements Matrix {
  7.  
  8.     public Immutable(int[][] matrix) {
  9.         super(matrix);
  10.     }
  11.     public Immutable() {
  12.  
  13.     }
  14.  
  15.   /*  @Override
  16.     public int[][] multiply(int[][] m) {
  17.         return super.multiply(m);
  18.     }*/
  19.  
  20.     @Override
  21.     public Matrix add(int[][] m) {
  22.         int[][] result = null;
  23.             result = new int[this.matrix.length][this.matrix.length];
  24.             for (int i = 0; i < this.matrix.length; i++) {
  25.                 for (int j = 0; j < this.matrix[i].length; j++) {
  26.                     result[i][j] = this.matrix[i][j] + m[i][j];
  27.                 }
  28.             }
  29.         return new Immutable(result);
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement