0
如何獲得此代碼的工作?我需要返回3個場景中的語句,目前我在String robotInfo處收到錯誤。返回聲明
String generateStatusReport(Robot robot) {
String robotStatus;
String robotWall;
String robotGround;
String robotInfo = robotStatus + robotWall + robotGround;
if(isRobotDead(robot)) {
robotStatus = ("The robot is dead.");
} else {
robotStatus = ("The robot is alive.");
if(isRobotFacingWall(robot)) {
robotWall = ("The robot is facing a wall.");
} else {
robotWall = ("The robot is not facing a wall.");
}
if(isItemOnGroundAtRobot(robot)) {
robotGround = ("There is an item here.");
} else {
robotGround = ("There is no item here.");
}
}
return robotInfo;
}