Abstract Classes

In an abstract class some features are not implemented. Only subclasses that implement these features can actually be used.


Example:
abstract class AbstRectangle {
    public Point origin;
    /* don't know whether the corner or
       the width and height will be stored */
    abstract Point Corner();
    abstract int Width();
    abstract int Height();
    
    public int Surface() {
        return Width() * Height();
    }
}

public class Rectangle extends AbstRectangle {
    /* we choose to store the corner */
    private Point corner;

    public Point Corner() {
        return corner;
    }
    public int Width() {
        return corner.x - origin.x;
    }
    public int Height() {
        return corner.y - origin.y;
    }
}