GREEN: implement command execution
This commit is contained in:
parent
9cc1ae42b0
commit
e292e66c64
1 changed files with 17 additions and 0 deletions
|
|
@ -41,4 +41,21 @@ class Rover {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void execute(String commands) {
|
||||
for (var i = 0; i < commands.length; i++) {
|
||||
final command = commands[i];
|
||||
switch (command) {
|
||||
case 'L':
|
||||
turnLeft();
|
||||
break;
|
||||
case 'R':
|
||||
turnRight();
|
||||
break;
|
||||
case 'M':
|
||||
moveForward();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue