adapt user interface to new report deliver method
This commit is contained in:
parent
ca9f150c23
commit
b50022b5b2
|
@ -37,14 +37,20 @@ public class RoverCommandsPerformer {
|
||||||
do {
|
do {
|
||||||
output("Insert command (f = forward, b = backward, l = turn left, r = turn right, q = quit):");
|
output("Insert command (f = forward, b = backward, l = turn left, r = turn right, q = quit):");
|
||||||
nextCommand = reader.next();
|
nextCommand = reader.next();
|
||||||
switch (nextCommand) {
|
var report = switch (nextCommand) {
|
||||||
case "f" -> moveForwardCommand.execute();
|
case "f" -> moveForwardCommand.execute();
|
||||||
case "b" -> moveBackwardsCommand.execute();
|
case "b" -> moveBackwardsCommand.execute();
|
||||||
case "l" -> turnLeftCommand.execute();
|
case "l" -> turnLeftCommand.execute();
|
||||||
case "r" -> turnRightCommand.execute();
|
case "r" -> turnRightCommand.execute();
|
||||||
case "q" -> output("Disconnecting from Mars...");
|
default -> null;
|
||||||
default -> output("unknown command");
|
};
|
||||||
}
|
if (report == null) {
|
||||||
|
if (nextCommand.equals("q"))
|
||||||
|
output("Disconnecting from Mars...");
|
||||||
|
else
|
||||||
|
output("unknown command");
|
||||||
|
} else
|
||||||
|
output(report.toString());
|
||||||
} while (isNotExitSignal(nextCommand));
|
} while (isNotExitSignal(nextCommand));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue