//////////////////////////////////////////////////////////////
// From JAVA PROGRAMMING: FROM THE BEGINNING, by K. N. King //
// Copyright (c) 2000 W. W. Norton & Company, Inc.          //
// All rights reserved.                                     //
// This program may be freely distributed for class use,    //
// provided that this copyright notice is retained.         //
//                                                          //
// Rectangle.java (Chapter 11, page 464)                    //
//////////////////////////////////////////////////////////////
// Represents a rectangle that can be displayed in a graphics
// context
import java.awt.*;
public class Rectangle extends Shape {
  // Instance variables
  private int width;
  private int height;
  // Constructor
  public Rectangle(int x, int y, Color color,
                   int width, int height) {
    super(x, y, color);
    this.width = width;
    this.height = height;
  }
  // Instance methods
  public void draw(Graphics g) {
    g.setColor(getColor());
    g.fillRect(getX(), getY(), width, height);
  }
  public int getHeight() {
    return height;
  }
  public int getWidth() {
    return width;
  }
}
syntax highlighted by Code2HTML, v. 0.9.1