示例#1
0
  /** @param args */
  public static void main(String[] args) {

    ShapeCache.loadCache();

    Shape clonedShape = ShapeCache.getShape("1");
    System.out.println("Shape : " + clonedShape.getType());

    System.out.println(clonedShape.hashCode());

    clonedShape = ShapeCache.getShape("2");
    System.out.println("Shape : " + clonedShape.getType());

    System.out.println(clonedShape.hashCode());

    clonedShape = ShapeCache.getShape("3");
    System.out.println("Shape : " + clonedShape.getType());

    System.out.println(clonedShape.hashCode());
  }
示例#2
0
 @Override
 public final boolean intersects(Shape otherShape) {
   switch (otherShape.getType()) {
     case CIRCLE:
       return Intersection.intersects((Circle) otherShape, this);
     case LINE:
       return Intersection.intersects(this, (Line) otherShape);
     case POINT:
       return Intersection.intersects(this, (Point) otherShape);
     case POLYGON:
       return Intersection.intersects((Polygon) otherShape, this);
     case RECTANGLE:
       return Intersection.intersects(this, (Rectangle) otherShape);
     default:
       return false;
   }
 }