这可能是一个非常愚蠢的问题,但我试图打印此输出,以便它只打印出system.out.println中的内容不是true / false。换句话说,我想摆脱真/假。
我知道还有其他问题,比如我的if (magic == false)
方法,但我只想专注于摆脱真/假。
public boolean magic() {
boolean diagMagic;
diagMagic = sumOtherDiag() == sumMainDiag();
int[] colArray = new int[square.length];
int[] rowArray = new int[square.length];
for (int k = 0; k < square.length; k++) {
rowArray[k] = sumRow(k);
}
for (int i = 0; i < square.length; i++) {
colArray[i] = sumCol(i);
}
boolean ifMagic = rowArray.equals(colArray);
boolean magic = ifMagic == diagMagic;
if(magic == false) {
System.out.println("This is a Magic Square");
} else
System.out.println("This is NOT a Magic Square");
return diagMagic;