
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;

public class Brick
{
    public static int WIDTH = 40;
    public static int HEIGHT = 10;
    public static Color COLORS[] = {Color.blue, Color.red, Color.green};
    
    public static Color SLOW = Color.darkGray;
    public static Color FAST = Color.lightGray;
    public static Color GROW = Color.cyan;
    public static Color SHRINK = Color.yellow;
      
    Color color;
    Rectangle r;
    
    boolean valid;
    boolean visible;
    boolean fast;
    boolean slow;
    boolean shrink;
    boolean grow;
    
    public Brick(int x, int y)
    {
        this(x, y, COLORS[(int)(COLORS.length*Math.random())]);
    }
    
    public Brick(int x, int y, Color color)
    {
        super();
        this.r = new Rectangle(x, y, WIDTH, HEIGHT);
        this.color = color;
        this.valid = true;
        this.visible = true;
        this.shrink = false;
        this.grow = false;
        this.fast = false;
        this.slow = false;
    }
    
    public void draw(Graphics g)
    {
        if ((valid) && (visible))
        {
            if (shrink)
                g.setColor(SHRINK);
            else if (grow)
                g.setColor(GROW);
            else if (slow)
                g.setColor(SLOW);
            else if (fast)
                g.setColor(FAST);
            else
                g.setColor(color);
            g.fill3DRect(r.x, r.y, r.width, r.height, false); 
            g.draw3DRect(r.x, r.y, r.width, r.height, false);
        }
    }
    
    public boolean contains(int x, int y)
    {
        if (valid)
            return r.contains(x, y);
        else
            return false;
    }
 
    public boolean isVisible()
    {
        return visible;
    }
    
    public void setValid(boolean valid)
    {
        this.valid = valid;
    }
    
    public boolean isValid()
    {
        return valid;
    }

    public boolean isFast()
    {
        return fast;
    }

    public void setFast(boolean fast)
    {
        this.fast = fast;
    }

    public boolean isSlow()
    {
        return slow;
    }

    public void setSlow(boolean slow)
    {
        this.slow = slow;
    }

    public boolean isShrink()
    {
        return shrink;
    }

    public void setShrink(boolean shrink)
    {
        this.shrink = shrink;
    }

    public boolean isGrow()
    {
        return grow;
    }

    public void setGrow(boolean grow)
    {
        this.grow = grow;
    }
    
    public boolean isSpecial()
    {
        return slow || fast || grow || shrink;
    }
}

