Back to 111 Main Page

Mobius strip

Assignment 7

Task

Expand the Circle class so that it implements two interfaces.

Details:

Wheels

Yet another version of wheels: intwheels.jar. This is coordwheels.jar with the addition of the two interfaces needed for this assignment.

Circle.java

Starting with the Circle from Assignment 6 (either your version or the provided solution), implement the two interfaces:

(These two files are already in the above .jar file. The source code provided here is just for your reference.)

Each of the two interfaces specify a single method that you will need to implement in Circle. The first part of your Circle.java file will look like this:

package wheels.users;

import wheels.Scalable;
import java.awt.Color;
import java.awt.Dimension;

/**
 * [your javadoc description of the class here,
 *  with @author and @version tags]
 */
public class Circle extends Ellipse implements SquareShape, Scalable {

Once you have implemented the two interfaces, test them by replacing the main method in Circle with this one:

  /**
   * Tests a Circle by drawing a bull's-eye of 3 concentric circles.
   */
  public static void main(String[] args) {
    Frame window = new Frame();

    //red outer circle
    Scalable outer = new Circle();
    outer.scale(3);

    //yellow middle circle
    SquareShape middle = new Circle();
    middle.setSize(100);
    //XXX: unsafe casts if middle isn't really a RectangularShape
    ((wheels.Colorable) middle).setColor(Color.yellow);
    ((wheels.Locatable) middle).setLocation(350, 250);

    //green inner circle
    Circle inner = new Circle(375, 275, 50, Color.green);

  }

What to Submit

Attach your Circle.java file to an email.

FAQ

Example code from lab?
Here: Square.java

Grading

Out of 10 points:

1 - Submission
Follows required submission policies.
2 - Coding standards
3 - Implements both interfaces
And builds on the previous version of Circle.
2 - Added methods are both correct
2 - Main method as given above


~ztomasze Index : TA Details: ICS111: Assignment 7
http://www2.hawaii.edu/~ztomasze
Last Edited: 10 Oct 2007
©2007 by Z. Tomaszewski.