package cse1030.test2;
import cse1030.drawing.Point2D;
/**
* A class for finding two dimensional points that match a point stored by a
* PointMatcher
object.
*
* @author CSE1030_F13_14
*
*/
public class PointMatcher {
/**
* The point stored by the PointMatcher
*/
protected Point2D point;
/**
* Creates a PointMatcher
object using the given point
* p
. The point p
is used by the matcher to define
* the matching criteria. This class matches points that are equal to
* p
, but subclasses are expected to define different matching
* criteria.
*
* @param p
* the point to match
*/
public PointMatcher(Point2D p) {
this.point = new Point2D(p);
}
/**
* Get the point that this PointMatcher
object uses to define the
* matching criteria. Clients cannot use this method to modify the point;
* clients must use setPoint
to modify the point that this
* PointMatcher
object matches.
*
* @return the point that this PointMatcher
uses to define the
* matching criteria.
*/
public Point2D getPoint() {
return new Point2D(this.point);
}
/**
* Set the point that this PointMatcher
object uses to define the
* matching criteria.
*
* @param p
* the point that this PointMatcher
should use to define
* the matching criteria.
*/
public void setPoint(Point2D p) {
this.point = new Point2D(p);
}
/**
* Checks whether or not the point other
matches the point held
* by this PointMatcher
. This PointMatcher
uses
* equals
to determine if its point matches other
,
* but subclasses of PointMatcher
are expected to change this
* behavior.
*
* @param other
* the point to check for a match
* @return true
if this PointMatcher
's point is
* equal to other
*/
public boolean matches(Point2D other) {
return this.point.equals(other);
}
}