Updated Sonarqube findings

This commit is contained in:
2022-06-29 10:41:37 -04:00
parent f73c7830c5
commit ee300f3da3
8 changed files with 530 additions and 598 deletions

View File

@@ -1,10 +1,12 @@
//Matrix/src/main/java/com/mattrixwv/matrix/ModMatrix.java
//Mattrixwv
// Created: 02-09-22
//Modified: 02-09-22
//Modified: 06-29-22
package com.mattrixwv.matrix;
import java.util.Arrays;
import com.mattrixwv.matrix.exceptions.InvalidGeometryException;
import com.mattrixwv.matrix.exceptions.InvalidScalarException;
@@ -215,7 +217,7 @@ public class ModMatrix extends IntegerMatrix{
}
//Create a new matrix for the product
ModMatrix newMatrix = clone();
ModMatrix newMatrix = new ModMatrix(this);
//Multiply the current grid power times
for(int currentPower = 1;currentPower < power;++currentPower){
newMatrix = newMatrix.multiply(this);
@@ -245,14 +247,6 @@ public class ModMatrix extends IntegerMatrix{
return new ModMatrix(super.transpose(), mod);
}
@Override
public int det(){
return determinant();
}
@Override
public int determinant(){
return super.determinant();
}
@Override
public ModMatrix cof(){
return cofactor();
}
@@ -322,28 +316,11 @@ public class ModMatrix extends IntegerMatrix{
//Object functions
@Override
public boolean equals(Object rightSide){
if(rightSide == null){
return false;
}
if(rightSide.getClass().equals(this.getClass())){
ModMatrix rightMatrix = (ModMatrix)rightSide;
//Make sure they have the same number of elements
if(getNumRows() != rightMatrix.getNumRows()){
return false;
}
else if(getNumCols() != rightMatrix.getNumCols()){
return false;
}
//Check every element
for(int row = 0;row < getNumRows();++row){
for(int col = 0;col < getNumCols();++col){
if(grid[row][col] != rightMatrix.grid[row][col]){
return false;
}
}
}
//If false hasn't been return yet then they are equal
return true;
return equals((ModMatrix)rightSide);
}
else if(rightSide.getClass().equals(int[][].class)){
int[][] rightMatrix = (int[][])rightSide;
@@ -354,16 +331,30 @@ public class ModMatrix extends IntegerMatrix{
return false;
}
}
public boolean equals(ModMatrix rightMatrix){
//Make sure they have the same number of elements
if((getNumRows() != rightMatrix.getNumRows()) || (getNumCols() != rightMatrix.getNumCols())){
return false;
}
//Check every element
for(int row = 0;row < getNumRows();++row){
for(int col = 0;col < getNumCols();++col){
if(grid[row][col] != rightMatrix.grid[row][col]){
return false;
}
}
}
//If false hasn't been return yet then they are equal
return true;
}
@Override
public int hashCode(){
return grid.hashCode();
return Arrays.hashCode(grid);
}
@Override
public String toString(){
return super.toString() + "\nmod(" + mod + ")";
}
@Override
public ModMatrix clone(){
return new ModMatrix(grid, mod);
}
}