So I rece ntly started an apprenticehsip and I am currently learning Java. I have been asked to write a public instance method moveBy() whose first argument is an int representing the distance to move and whose second argument is a char representing the direction in which to move. It should return no value.
Table 1: Directions and corresponding x and y increments
direction xInc yInc
right 'R' 1 0
left 'L' -1 0
up 'U' 0 -1
down'D' 0 1
Begin by declaring local int variables xInc and yInc and use the table above to set these for the appropriate increments depending on the supplied argument for direction.
The method should then move the Shape (class) the required distance and direction 1 step at a time, using a loop.
I have only done the method so far.. the argumets are not correct!