
Patrick B. answered 05/26/20
Math and computer tutor/teacher
Not sure how your grid is set up but you have to change row and column depending on the direction it is facing. You should also pass an integer which tells how many cells to move and also you will need to check
to make sure it does not go off the grid.
Also , you should declare constant MAX=14;
#define MAX (14)
Assuming row major, then:
Move ( int n)
{
switch (this.facing)
{
case NORTH:
{
row = (row>n) ? (row-n) : 0;
break;
}
case SOUTH:
{
row = ((row+n)
break;
}
case EAST:
{
col = (col < n) ? col-n:0;
break;
}
case WEST:
{
col = ( (col+n)
break;
}
}