/*
 * Part.java
 *
 * Created on 17 July 2002, 14:24
 */



/**
 *
 * @author  gbspashj
 */

import java.awt.*;

public abstract class Part {
    public static final int NONE = -1;
    public static final int LEFT = 0;
    public static final int UP = 1;
    public static final int RIGHT = 2;
    public static final int DOWN = 3;
    
    protected int x;
    protected int y;
    protected Part next;
    protected Part last;
  
    public Part( int x, int y ) {
        setX( x );
        setY( y ); 
    }
     
    public void moveDelta( int dir, int dist ) {
    }
    

    public Part getNext() {
        return next;
    }
    
    public void setNext( Part n ) {
        next = n;
    }
    
    public Part getLast() {
        return last;
    }
    
    public void setLast( Part l ) {
        last = l;
    }
    
    public int getX() {
        return x;
    }
    
    public int getY() {
        return y;
    }
    
    public void setX( int x ) {
        this.x = x;
    }
    
    public void setY( int y ) {
        this.y = y;
    }
    
    public boolean contains( int px, int py ) {
        boolean ret = false;

        if ( last != null ) {
            int h = last.getX();
            int k = last.getY();

            int x1, y1, x2, y2;
            if ( x < h ) {
                x1 = x;
                x2 = h;
            } else {
                x1 = h;
                x2 = x;
            }
            if ( y < k ) {
                y1 = y;
                y2 = k;
            } else {
                y1 = k;
                y2 = y;
            }

            if ( px < x1 || px > x2 || py < y1 || py > y2 )
                ret = false;
            else
                ret = true;
        }
        
        return ret;
    }
}
