Fix sonarqube findings

This commit is contained in:
2022-08-20 13:54:26 -04:00
parent 8f35397177
commit a845925f99
4 changed files with 4 additions and 5 deletions

View File

@@ -48,8 +48,7 @@ public class Triple<T, U, V>{
if(this == o){
return true;
}
else if(o instanceof Triple<?, ?, ?>){
Triple<?, ?, ?> rightSide = (Triple<?, ?, ?>)o;
else if(o instanceof Triple<?, ?, ?> rightSide){
return (a.equals(rightSide.a) && b.equals(rightSide.b) && c.equals(rightSide.c));
}
else{

View File

@@ -51,7 +51,7 @@ public class HexagonalNumberGenerator implements Iterator<Long>{
}
public static boolean isHexagonal(Long x){
Long n = Math.round((Math.sqrt(1 + (8 * x)) + 1) / 4);
Long n = Math.round((Math.sqrt(1.0 + (8 * x)) + 1) / 4);
return ((2 * n * n) - n) == x;
}
}

View File

@@ -51,7 +51,7 @@ public class PentagonalNumberGenerator implements Iterator<Long>{
}
public static boolean isPentagonal(Long x){
Long n = Math.round((Math.sqrt(1 + (24 * x)) + 1) / 6);
Long n = Math.round((Math.sqrt(1.0 + (24 * x)) + 1) / 6);
return (((3 * n * n) - n) / 2) == x;
}
}

View File

@@ -51,7 +51,7 @@ public class TriangularNumberGenerator implements Iterator<Long>{
}
public static boolean isTriangular(Long x){
Long n = Math.round((Math.sqrt(1 + (8 * x)) - 1) / 2);
Long n = Math.round((Math.sqrt(1.0 + (8 * x)) - 1) / 2);
return (((n * n) + n) / 2) == x;
}
}