For today's lab you must use the files listed below. Create a folder in your computer and save the files inside the folder.
Canvas.java
Square.java
MouseButtons.java
Board.java
When you create the Eclipse project for this lab, choose the option Create project from existing source
in the project creation wizard:
You will need to change two files for this lab and turn them in at the end of the lab:
Preliminary Information:
When the program starts a canvas is created and displayed on a window. The canvas dimensions are 400x400 pixels. The java
file Canvas.java takes care of creating the canvas and displaying it on the screen. You do not need to worry about this.

The canvas contains a gray square in the middle. The square is created in the constructor of the class Board.java in the line
targetSquare = new Square( 180, 180, 40, "gray", true, "");
The first two numbers (=180) in the line specify the x-value and y-value of the lower-left corner of the square inside the canvas.
The third number (=40) specifies the size of the square. The "gray" specifies the color. The value "true" specifies the visibility,
that is that the square is visible. The last parameter "" assigns a label to the square. Since we do not need the label in this lab,
this parameter is the empty string.
The canvas is preconfigured to listen to mouse events. For now it only listens to the event mousePressed. When the mouse
is pressed on any point on the canvas, the method void handleMouseClick(int mouseX, int mouseY) inside the class
Board.java is executed. This method receives in input two int values, mouseX and mouseY, which are the x-value and
y-value of the point of the canvas that has been clicked. You need to modify this method in order to complete the 3 stages
of this lab.
Stage 1:
Display a message on the console when the mouse click is inside the square. You will need to use:
theSquare.getX(), which returns the x-value of the lower-left corner of the square.
theSquare.getY(), which returns the y-value of the lower-left corner of the square.
theSquare.getSize(), which returns the size of the square. The execution of the program might look like below:

Each time the mouse is clicked, a message must be displayed on the console telling if the square was clicked upon or not. The message must also display the coordinates of the clicked point.
Hint: You have the coordinates of the point that was clicked upon in input. You can also get the coordinates and size of the lower-left corner of the square with the three methods listed above. How can you figure out if the point represented by the two coordinates in input is inside the 4 lines of the square?
Stage 2:
Move the square 40 pixels to the right when it is clicked upon. You will only need to use:
theSquare.setPosition( newX, newY);
Once the square reaches the far right side, it should reverse direction and go to the left when it is clicked upon. Similarly again it should reverse direction when it reaches the left margin.
Remember the canvas dimensions are 400x400 pixels. The code from stage 1 should remain in place, you only need to add more to it.
Stage 3 (Advanced):
Have the Square move to a random screen position once it is clicked upon. In order to move the square to a random position, you will first need to create random numbers, which can be used to specify random coordinates. For sample code using a random number generator, see:
http://logos.cs.uic.edu/Program%20Assignment%20Archive/09%20Fall/Program2Boggle/Board.java
Hints about the link above: Notice how you need to create a random number generator object at the beginning of the class Board.java. You can then use that object as shown in the method getLetter().
For a solution look at the file Board.java.