Modify this code.
- It is not good programming practice to work directly on the class variables
of a point, as the code above does. Instead, each class should have methods
for accessing and modifying the class variables. In this case, we need methods to set the values for the x and y coordinates, and to return them to the user. Call them setX, setY, getX and getY.
Modify (extend) the myPoint class with these methods.
- Modify the myPoint class so that an object of this type
retains not only the x and y coordinates of a point, but also a
shape (e.g. this can be an integer variable. It may have the value 0
for square and 1 for circle) and a color for it. The shape and
color are meant to be used by the Draw method when drawing the
image of the point on the applet's screen.
- Modify the constructor method to initialize an object of type
myPoint with a default shape and a default color.
- Modify the Print method to also print the new information on
the Java console.
- Modify the Draw method to draw the point with the
corresponding shape and color.
- Modify the main applet to include two buttons, Color and
Shape. Clicking on the Color button toggles the color of the
current point between black and red. Pressing the Shape button
toggles the shape of the current point between a small circle and
a small square. At this point you should be able to write,
compile and test the whole applet.