でこのエラーが発生し、lastStartCol = FC_COLS – inBlockSize;
で同様のエラーが発生しlastStartCol = ECONOMY_COLS – inBlockSize;
ます。また、私の先生が for ステートメントで私に何をしてほしいのかわかりません。簡単な回答をいただければ幸いです。
//行内の指定されたブロック サイズの //最後の正当な開始列である lastStartCol を決定します。
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;
}
}
}
}