java - FC_COLS 的原始类型 int 没有字段 inBlockSize

标签 java eclipse

我在 lastStartCol = FC_COLS – inBlockSize; 上收到此错误,并且在 lastStartCol = ECONOMY_COLS – inBlockSize; 上收到类似的错误。也不确定我的老师希望我用 for 语句做什么。简单的答案表示赞赏。

//确定lastStartCol,行中给定 block //大小的最后一个合法起始列。

if(inRow < FC_ROWS)
    lastStartCol = FC_COLS – inBlockSize;
else
    lastStartCol = ECONOMY_COLS – inBlockSize;


for(int startCol = 0; startCol <= lastStartCol; startCol++)
{
    ...

全类:

public class Airplane 
{
private Seat [ ] [ ] seats;
public static final int FIRST_CLASS = 1;
public static final int ECONOMY = 2;
private static final int FC_ROWS = 5;
private static final int FC_COLS = 4;
private static final int ECONOMY_ROWS = 5;
private static final int ECONOMY_COLS = 6;

public Airplane() 
{
    seats  = new Seat[FC_ROWS][FC_COLS]; 
    for (int i=0; i<FC_ROWS; i++) {
        for (int j=0; j<FC_COLS; j++) 
        {
            seats[i][j] = new Seat(Seat.WINDOW);
        }
        seats  = new Seat[ECONOMY_ROWS][ECONOMY_COLS]; 
        for (int x=0; x<ECONOMY_ROWS; x++) {
            for (int y=0; y<ECONOMY_COLS; y++) 
            {
                seats[x][y] = new Seat(Seat.WINDOW);
            }
        }
    }
}
public String toString()
{
    String str = "";
    for (int i=0; i<FC_ROWS; i++) {
        for (int j=0; j<FC_COLS; j++) 
        {
            str= str + seats[i][j].toString();
        }
        str = str + "\n";
    }
    return str;
}   

public String toString2()
{
    String z = "";
    for (int x=0; x<ECONOMY_ROWS; x++) {
        for (int y=0; y<ECONOMY_COLS; y++) 
        {
            z= z + seats[x][y].toString();
        }
        z = z + "\n";
    }
    return z;
}
private int findEmptyBlockInRow(int inRow, int inBlockSize, int inSeatType)
{
    int lastStartCol;

    //Determine lastStartCol, the last legal start column for the given block //size in the row.
    if(inRow < FC_ROWS)
        lastStartCol = FC_COLS – inBlockSize;
    else
        lastStartCol = ECONOMY_COLS – inBlockSize;


    for(int startCol = 0; startCol <= lastStartCol; startCol++)
    {
        ...

        //Starting at startCol, check for inBlockSize consecutive seats //that are empty and include the seat type you are looking for. If //a seat block is found, return the startCol. 

        for(int i = 0; i < inBlockSize; i++)
        {
            if (seats[inRow][startCol + i].isAvailable()==true)  
            {
                int f = 0;
                f++;
            }


            if (seats[inRow][startCol + i].getSeatType() == inSeatType)
            {
                int d = inSeatType;
            }

            return lastStartCol;
        }

    }
}
 }

最佳答案

我的理解是打字错误。

尝试像此行lastStartCol = FC_COLS - inBlockSize; 首先删除此-,然后再次从键盘输入减号。

也从这一行执行上述操作lastStartCol = ECONOMY_COLS - inBlockSize;

或者

尝试用下面的代码替换您的代码行。

if(inRow < FC_ROWS)
    lastStartCol = FC_COLS - inBlockSize;
else
    lastStartCol = ECONOMY_COLS - inBlockSize;

关于java - FC_COLS 的原始类型 int 没有字段 inBlockSize,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15827029/

相关文章:

java - 字符串替换功能在android中不起作用

java - 如何在 Struts 2 中更改 JSESSIONID

java - 写入文件java

java - 在eclipse上创建android项目时出错

eclipse - eclipse中方法/类名称上的 "i"图标是什么意思

c++ - 如何告诉我的 Eclipse Helios CTD 项目是 C/C++ 项目?

java - 玩! : How to place property value in groovy expression

java - Java 中的文本到莫尔斯电码转换器

android - 单击按钮后如何创建菜单组?

java - Eclipse Kepler for OS X Mavericks 请求 Java SE 6