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 { 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));
} }
} }