import java.awt.*;

/**
 * Write a description of class ColorRect here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class ColorRect extends Rectangle implements Colorable
{
    protected Color myColor;

    ColorRect() {
        myColor = Color.green;
    }
    ColorRect(int w, int h) {
        myColor = Color.blue;
    }
    ColorRect(int w, int h, Color c) {
        myColor = c;
    }
    public void setColor(Color c) {
        myColor = c;
    }
    public Color getColor() {
        return myColor;
    }
    public void draw(DrawingBox box, int x, int y) {
        box.setColor(myColor);
        box.fillRect(x, y, width, height);  // protected lets us access these 
                                            // instance variables directly in the
                                            // subclass
    }
    public static void main (String [] args)
    {
        DrawingBox box = new DrawingBox();
        
        Rectangle colorless = new Rectangle(100, 50);
        System.out.println("Rectangle colorless:\n    " + colorless);

        if (colorless instanceof Rectangle) {
            System.out.println("colorless is the super type.");
        }
        if (colorless instanceof ColorRect) {
            System.out.println("colorless is the sub type.");   
        }
        
        ColorRect r = new ColorRect(250,150);
        r.setColor(Color.pink);
        System.out.println("Rectangle r:\n    " + r);
        
        if (r instanceof Rectangle) {
            System.out.println("is the super type.");
        }
        if (r instanceof ColorRect) {
            System.out.println("is the sub type.");   
        }
        ColorRect r2 = new ColorRect(250,200);
        System.out.println("ColorRect r2:\n    " + r2);
        
        if (r2 instanceof Rectangle) {
            System.out.println("r2 is the super type.");
        }
        if (r2 instanceof ColorRect) {
            System.out.println("r2 iss the sub type.");   
        }
    
        r.draw(box, 10, 10);
        colorless.draw(box, 10, 300);
        r2.draw(box, 300,300);

    }
}
