Java 不确定代码的逻辑

Java 不确定代码的逻辑,java,Java,我还不能手动测试我的方法的代码,因为我还没有完成其他相关代码的测试,但我觉得该方法的逻辑public boolean isFilledAt(int row,int col)是错误的。如果形状在给定行/列位置有一个填充块(任意char),则该方法返回true;如果块为空(点”,则返回false。)。如果该位置超出范围,则使用信息性消息引发一个FitItException。smb是否可以查看它并让我知道该方法的代码是否有任何错误?谢谢 public class CreateShape {

我还不能手动测试我的方法的代码,因为我还没有完成其他相关代码的测试,但我觉得该方法的逻辑
public boolean isFilledAt(int row,int col)
是错误的。如果形状在给定行/列位置有一个填充块(任意
char
),则该方法返回
true
;如果块为空(点
”,则返回
false
)。如果该位置超出范围,则使用信息性消息引发一个
FitItException
。smb是否可以查看它并让我知道该方法的代码是否有任何错误?谢谢

public class CreateShape {

    private int height;
    private int width;
    private char dc;
    private Rotation initialPos;
    private char[][] shape = new char[height][width]; 
public boolean isFilledAt(int row, int col) 
    {
        if(row < 0 || row >= height || col < 0 || col >= width)
            throw new FitItException("Oops! Out of bounds!");
        else
        {
            for (int i = 0; i < shape.length; i++)
                for (int j = 0; j < shape[i].length; j++) {
                    if (shape[row][col] == dc)
                        return true;
                }
        }
        return false;
    }
公共类CreateShape{
私人内部高度;
私有整数宽度;
私人区议会;
私人轮换;
私有字符[][]形状=新字符[高度][宽度];
公共布尔值isFilledAt(整数行,整数列)
{
如果(行<0 | |行>=高度| |列<0 | |列>=宽度)
抛出新的FitException(“哎呀!出界!”);
其他的
{
对于(int i=0;i
公共布尔值isFilledAt(int行,int列){
如果(行<0 | |行>=高度| |列<0 | |列>=宽度)
抛出新的FitException(“哎呀!出界!”);
其他的
返回(形状[行][col]==dc);
}

与您当前的代码相同。我不确定您通过数组的目的是什么,您甚至没有使用
I
j
变量。

您需要迭代吗?:):),不能简单地思考!@PrashantGhimire谢谢,我现在就要更改它!
public boolean isFilledAt(int row, int col) {
    if(row < 0 || row >= height || col < 0 || col >= width)
        throw new FitItException("Oops! Out of bounds!");
    else 
        return (shape[row][col] == dc);
}