Lab 4 (Feb 4-5)

1. Circles

Draw a few circles of various colors and shapes.

Call your program

Your output may look like this: Step1 demo.

We have included a small template to get you started.

Note that the approach is not object oriented at all, but that doesn't matter as far as rendering (the graphical part of this program) goes.

2. A Circle Class
Do exactly the same thing as in step 1, but program things differently.

Define a Circle class, which has:

Make all instance variables private.

Your program's ( output should be unchanged.

3. In Which We Get User Input
Change your program ( to accept user input.

Define three functions:

It is useful to define a method
void jumpTo(int x, int y)
in class Circle which is called by mouseDragged.

Another useful method that you may want to define is a

boolean inside(int x, int y)
which determines if the point determined by the coordinates that are being passed as parameters is inside the circle to which the method belongs or not.

Also, with this program you need to set your method of drawing to XOR (as explained in the lecture).

Here's what the program should look like when you're done with this step.

4. In Which the Circles Start Moving
Add movement to your program's world.

Disable (comment out) the functions that handle mouse input and allow the circles to move in arbitrary directions, bouncing off an imaginary rectangle border that surrounds the image.

Here are a few guidelines:

Call your program

Here's a demo for it.

5. Movement With User Input
So far we have developed in two directions: Now we put these two directions together.

Allow the movement and the user selection to interfere.

Here are some guidelines:

Call your program It should work like this.