previous | start | next

## When Not to Use Inheritance

- Huh? A circle isn't a point.
- By accident, inherited `translate` works for circles
- Same tutorial makes `Rectangle` a subclass of `Point`:

      public class Rectangle extends Point // DON'T
      {
         public Rectangle(Point corner1, Point corner2) { ... }
         public void draw(Graphics g) { ... }
         public void translate(int dx, int dy) { ... }
         private Point other;
      }

previous | start | next