Help with object orientated Java code for movement of snake. I need to implement four methods for up

Help with object orientated Java code for movement of snake. I need to implement four methods for up, down, left and rightfor movement of the snake, well the head part at least that makere-use of a method that calculates a lot of this already. Themethod in need to call in is : private void moveTo(int newHeadX, int newHeadY) //provided
{
int oldHeadX = getHeadXPos();
int oldHeadY = getHeadYPos();
int oldBodyX = getBodyXPos();
int oldBodyY = getBodyYPos();
if (checkX(newHeadX) && checkY(newHeadY))
{
head.setXPos(newHeadX);
head.setYPos(newHeadY);
delay(100);
body.setXPos(oldHeadX);
body.setYPos(oldHeadY);
delay(100);
tail.setXPos(oldBodyX);
tail.setYPos(oldBodyY);
delay(100);
}
else
{
System.out.println(“Snake cannot cross boundary!”);
} Based on what i know about this, it should be a fairly shortpiece of code to implement as it mainly uses the above method, butcan’t for the life of me figure this out. Here’s the question that accompanies it and the diameter of thehead movement is 10 : “In this part of the question you will write methods to move thesnake one place, to the right, left, up or down. Remember that whena snake moves, first the head moves (according to which methodyou’re writing), then the body moves to where the head was, thenthe tail moves to where the body was. Note the delay() methodprovided for you. This allows a delay to be inserted after each ofthe head moving, the body moving, and the tail moving. Withoutthis, the movement might be too quick for you to observe. Consider the provided helper method moveTo(int newHeadX, intnewHeadY). This method determines whether or not the position of ahead with this x position and yposition would be valid, and if so,moves the head to that position, then moves the body to where thehead was, then moves the tail to where the body was, delaying aftereach move as described above. If there is not enough room for thesnake to move to the new position, then the message “Snake cannotcross boundary!” is output. Uncomment the lines of code in thismethod now. Write the public instance method right() which has no argumentsand returns no value. This method should calculate the new positionof the head, one head diameter to the right of where it currentlyis, and then move the snake to that position if possible. Write the public instance method left() which has no argumentsand returns no value. This method should calculate the new positionof the head, one head diameter to the left of where it currentlyis, and then move the snake to that position if possible. Write the public instance method up() which has no arguments andreturns no value. This method should calculate the new position ofthe head, one head diameter above where it currently is, and thenmove the snake to that position if possible. Write the public instance method down() which has no argumentsand returns no value. This method should calculate the new positionof the head, one head diameter below where it currently is, andthen move the snake to that position if possible.” Attached