Main Page

Previous Next

Exercises

  1. Add the code to the Sketcher program to support drawing an ellipse.

  2. Modify the Sketcher program to include a button for switching fill mode on and off.

  3. Extend the classes defining rectangles, circles and ellipses to support filled shapes.

  4. Extend the curve class to support filled shapes.

  5. (Harder – for curve enthusiasts!) Implement an applet to display a curve as multiple CubicCurve2D objects from points on the curve entered by clicking the mouse. The applet should have two buttons – one to clear the window and allow points on the curve to be entered, and the other to display the curve. Devise your own scheme for default control points.

  6. (Also harder!) Modify the previous example to ensure that the curve is continuous – this implies that the control points either side of an interior point, and the interior point itself, should be on a straight line. Allow control points to be dragged with the mouse, but still maintaining the continuity of the curve.

Previous Next
JavaScript Editor Java Tutorials Free JavaScript Editor