1
0
Fork 0

loop the world forward successful

This commit is contained in:
Xavier Fontanet 2024-06-20 21:26:14 +02:00
parent eac2fb3446
commit 48b5b55ae0
1 changed files with 6 additions and 1 deletions

View File

@ -33,7 +33,12 @@ public class MarsMap {
var newLongitude = currentPosition.getLongitude(); var newLongitude = currentPosition.getLongitude();
switch (direction) { switch (direction) {
case NORTH -> newLatitude--; case NORTH -> newLatitude--;
case SOUTH -> newLatitude++; case SOUTH -> {
if (newLatitude+1 > height)
newLatitude=1;
else
newLatitude++;
}
case WEST -> newLongitude--; case WEST -> newLongitude--;
case EAST -> newLongitude++; case EAST -> newLongitude++;
} }