/**
 * Created by IntelliJ IDEA.
 * User: gloyaute
 * Date: 10 06 2011
 * Time: 21:09:31
 * To change this template use File | Settings | File Templates.
 */

public class PolyLine {
    private Point[] points;
    private int count = 0;

    public PolyLine(int capacity) {
        if (capacity < 0) {
            throw new NegativeArraySizeException();
        }
        points = new Point[capacity];
    }

    public void add(Point p) {
        if (count == points.length) {
            throw new ArrayStoreException(); 
        }
        points[count++] = p;
    }

    public int pointCapacity() {
        return points.length;
    }

    public int pointCount() {
        return count;
    }

    public boolean contains(Point p) {
        int i = 0;
        for (; i < points.length && !points[i].equals(p); ++i);

        if (i == points.length) {
            return false;
        }
        return true;
    }
}
