我已经阅读了与该主题相关的其他一些问题,老实说,我对所提供的答案感到非常迷茫,而我确实理解的那些似乎不起作用。
我正在介绍 ap comp sci 课程,所以更简单的答案将不胜感激。我的飞机构造函数出现错误,上面的错误是什么,不知道如何解决它我尝试使用超级方法但也许我做错了,因为错误仍然存在。
飞机等级:
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][ECONOMY_COLS];
}
public String toString() {
String str = "";
for (int i = 0; i < FC_ROWS; i++) {
for (int j = 0; j < ECONOMY_COLS; j++) {
str = str + seats[i][j].toString();
}
str += "\n";
}
return str;
}
public class Seat {
private int seatType;
private boolean isReserved;
public static final int WINDOW = 1;
public static final int AISLE = 2;
public static final int CENTER = 3;
public Seat(int inSeatType) {
seatType = inSeatType;
isReserved = false;
}
public int getSeatType() {
return seatType;
}
public void reserveSeat() {
isReserved = true;
}
public boolean isAvailable() {
if (isReserved = false) {
return true;
} else {
return false;
}
}
public String toString() {
if (isReserved == false) {
return "*";
} else {
return "";
}
}
}
}