1
0
Fork 0

adapt user interface to new report deliver method

This commit is contained in:
Xavier Fontanet 2024-07-05 17:51:49 +02:00
parent ca9f150c23
commit b50022b5b2
1 changed files with 10 additions and 4 deletions

View File

@ -37,14 +37,20 @@ public class RoverCommandsPerformer {
do {
output("Insert command (f = forward, b = backward, l = turn left, r = turn right, q = quit):");
nextCommand = reader.next();
switch (nextCommand) {
var report = switch (nextCommand) {
case "f" -> moveForwardCommand.execute();
case "b" -> moveBackwardsCommand.execute();
case "l" -> turnLeftCommand.execute();
case "r" -> turnRightCommand.execute();
case "q" -> output("Disconnecting from Mars...");
default -> output("unknown command");
}
default -> null;
};
if (report == null) {
if (nextCommand.equals("q"))
output("Disconnecting from Mars...");
else
output("unknown command");
} else
output(report.toString());
} while (isNotExitSignal(nextCommand));
}
}