java新手。通过遵循一本书来练习编码。
这是我的代码:
class Motorcycle {
//Three instance variables - make and color are strings. while a boolean refers to TRUE OR FLASE(in this case off or on)
String make;
String color;
boolean engineState;
void startEngine() {
if (engineState == true)
System.out.print("The engine is already on.");
else {
engineState = true;
System.out.print("The engine is now on.");
}
void showAtts() {
System.out.print("This motorcycle is a " + color + " " + make);
if (engineState ==true)
System.out.print("The engine is on.");
else System.out.print("The engine is off.");
}
}
}
编译时出现 2 个错误:
1) 表达式 2) 的非法开始;预期的
我无法确定问题所在。如果有人可以指导我或暗示我,请做。