//Is this any better?
double area2(Object shape) {
    if (shape instanceof Circle) {
        Circle circle = (Circle) shape;
        return Math.PI * circle.getRadius() * circle.getRadius();
    } else if (shape instanceof Rectangle) {
        Rectangle rectangle = (Rectangle) shape;
        return rectangle.getWidth() * rectangle.getHeight();
    } else if (shape instanceof Square) {
        Square square = (Square) shape;
        return square.getSize() * square.getSize();
    }
    throw new IllegalArgumentException("Unknown shape");
}

--> shape.getArea();

public class Shape{
    public double getArea(){ return 0 };
}

//let each class such as Circle, Rectangle, Square extend Shape 

