Class MyFactory

java.lang.Object
  extended bym865.shapepack.ShapeFactory
      extended byMyFactory

public class MyFactory
extends ShapeFactory

MyFactory class is a factory class which extends the ShapeFactory in the package edu.clemson.mthsc865.shapepack. It adds a Circle shape to the catalog of shapes available from the ShapeFactory superclass.

Version:
1.0 09/04/05
Author:
Daniel D. Warner

Field Summary
static java.lang.String CIRCLE
           
 
Fields inherited from class m865.shapepack.ShapeFactory
ELLIPSE, RECTANGLE, SQUARE, theList
 
Constructor Summary
MyFactory()
          The generic MyFactory constructor This constructor adds additional shapes to theList
 
Method Summary
 Shape createShape(java.lang.String shapeName, int x, int y)
          Creates a specified shape with a default color and a bounding box of the default size.
 Shape createShape(java.lang.String shapeName, int x, int y, int w, int h, java.awt.Color c)
          Creates a specified shape
static void main(java.lang.String[] args)
          Provides a unit test.
 java.lang.String toString()
          Overrides: toString in class ShapeFactory
 
Methods inherited from class m865.shapepack.ShapeFactory
getTheList
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CIRCLE

public static final java.lang.String CIRCLE
See Also:
Constant Field Values
Constructor Detail

MyFactory

public MyFactory()
The generic MyFactory constructor This constructor adds additional shapes to theList

Method Detail

createShape

public Shape createShape(java.lang.String shapeName,
                         int x,
                         int y,
                         int w,
                         int h,
                         java.awt.Color c)
Creates a specified shape

Overrides:
createShape in class ShapeFactory
Parameters:
shapeName - the name of the shape.
x - the horizontal coordinate of the upper left corner of the bounding box.
y - the vertical coordinate of the upper left corner of the bounding box.
w - the width of the bounding box.
h - the height of the bounding box.
c - the fill color of the shape.
Returns:
an instantiation of the specified shape. If the name is not a shape in the list, then this method returns the default shape returned by ShapeFactory.

createShape

public Shape createShape(java.lang.String shapeName,
                         int x,
                         int y)
Creates a specified shape with a default color and a bounding box of the default size.

Overrides:
createShape in class ShapeFactory
Parameters:
shapeName - the name of the shape.
x - the horizontal coordinate of the upper left corner of the bounding box.
y - the vertical coordinate of the upper left corner of the bounding box.
Returns:
an instantiation of the specified shape. If the name is not a shape in the list, then this method returns the default shape returned by ShapeFactory.

toString

public java.lang.String toString()
Overrides: toString in class ShapeFactory

Overrides:
toString in class ShapeFactory
Returns:
a formatted string with the class name and the list of shapes this factory can construct.

main

public static void main(java.lang.String[] args)
Provides a unit test.
  1. Creates an instance of MyFactory and prints out the toString info.
  2. Creates a shape corresponding to each input argument and prints out that shape's toString info.