## how to make the worm move

I'm stuck now after finishing drawing the worm using Queue and Point class. The function I used to draw the worm is draw( first_point.getX(),
first_point.getY(), second_point.getX(), second_point.getY).

I'm grateful if anyone can help me figure out how to do this - worm movement. The following is the hint from my teacher. I think it's very complete, but I got confused with "looking at the two points", "calculating new head"...

-------------------------------------------------
When the move() method of the Worm class is invoked a new head for the worm has to be calculated. Once the new head is calculated it is added to the queue and the tail of the worm is removed from the queue. Also during this time the new head has to be drawn in the window and the old tail has
to be erased.

The new head is determined by looking at the two points at the head of the worm (which is the tail of the Queue):

-01 012 12- 2--
-*2 -*- 0*- 1*@
@-- -@- --@ 0--

--@ -@- @-- --0
2*- -*- -*0 @*1
10- 210 -21 --2

Notice that there are eight cases to consider where the * represents the point at the head of the worm and the @ represents the point right before the head. Once the correct case is selected there are three possible positions for the new head of the worm (represented by the numbers 0, 1 and 2). You should use the random() function to pick a random number to decided which of these three points will be the new head for the worm. Once the new head is calculated you also need to wrap it if it moves off any side of the window.
When the move() method of the Worm class is invoked a new head for the worm has to be calculated. Once the new head is calculated it is added to the queue and the tail of the worm is removed from the queue. Also during this time the new head has to be drawn in the window and the old tail has
to be erased.

--------------------------------------------

To look at the two points, I coded