Site hosted by Angelfire.com: Build your free website today!
 

Example

  • Download the sample project (zipped) for the example.

  • Invoke eclipse

    • Create a new project

    • Import the zipped file into the project

    • Study the java programs

      ./graphicalobject/BaseGraphicElem.java
      ./graphicalobject/Coordinate.java
      ./graphicalobject/impl/Rectangle.java
      ./graphicalobject/impl/Circle.java
      ./graphicalobject/GraphicElement.java
      ./drawing/Drawing.java
      ./DrawingEditor.java
  • Run the program and look at the result

  • Try the follwoing:

    1. In the Coordinate class, change the access keyword for the instance variable x to private.

    2. In the GraphicElement interface, add a method definition public void setColor(String color).

    3. In the BaseGraphicElem class, change the method public void move(Coordinate coord) to final