简体   繁体   English

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

[英]The primitive type int of FC_COLS does not have a field inBlockSize

I am getting this error on the lastStartCol = FC_COLS – inBlockSize; 我在lastStartCol = FC_COLS – inBlockSize;上收到此错误lastStartCol = FC_COLS – inBlockSize; and a similar error with lastStartCol = ECONOMY_COLS – inBlockSize; lastStartCol = ECONOMY_COLS – inBlockSize;类似的错误lastStartCol = ECONOMY_COLS – inBlockSize; . Also not to sure what my teacher wants me to do with the for statement.Simple answers appreciated. 同样也不确定老师希望我用for语句做什么。简单的答案表示赞赏。

//Determine lastStartCol, the last legal start column for the given block //size in the row. //确定lastStartCol,该行中给定块//的最后合法起始列。

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


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

Whole Class: 全班:

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;
        }

    }
}
 }

My understanding is something mistake by typing. 我的理解是打字错误。

Try this like in this line lastStartCol = FC_COLS - inBlockSize; 在此行中像这样尝试lastStartCol = FC_COLS - inBlockSize; first remove this - and again enter the minus symbol from keyboard. 首先将其删除-再次从键盘输入减号。

do the above from this line also lastStartCol = ECONOMY_COLS - inBlockSize; 从此行也执行上述操作lastStartCol = ECONOMY_COLS - inBlockSize;

OR 要么

Try to replace your line of code with below. 尝试用下面的代码替换您的代码行。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM