GREEN: implement move forward
This commit is contained in:
parent
36003654c7
commit
c6235bd38a
1 changed files with 17 additions and 0 deletions
|
|
@ -24,4 +24,21 @@ class Rover {
|
|||
};
|
||||
direction = rightTurns[direction]!;
|
||||
}
|
||||
|
||||
void moveForward() {
|
||||
switch (direction) {
|
||||
case 'N':
|
||||
y += 1;
|
||||
break;
|
||||
case 'E':
|
||||
x += 1;
|
||||
break;
|
||||
case 'S':
|
||||
y -= 1;
|
||||
break;
|
||||
case 'W':
|
||||
x -= 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue