// Exercise 1: extends, super, and overriding
//
// Implement the Shape / Circle / Square hierarchy below:
//   - Shape has a String color field, a constructor taking color, and a
//     method describe() returning "A " + color + " shape"
//   - Circle extends Shape, adds double radius, constructor(color, radius)
//     calling super(color); overrides describe() to return
//     super.describe() + " (circle, area=" + area() + ")"
//     where area() returns Math.PI * radius * radius
//   - Square extends Shape, adds double side, constructor(color, side)
//     calling super(color); overrides describe() to return
//     super.describe() + " (square, area=" + area() + ")"
//     where area() returns side * side

public class java_inheritance_and_polymorphism_exercise_1 {

    static class Shape {
        String color;

        Shape(String color) {
            // TODO: assign field
        }

        String describe() {
            // TODO: implement
            return null;
        }
    }

    static class Circle extends Shape {
        double radius;

        Circle(String color, double radius) {
            super(color); // provided — must be the first statement
            // TODO: assign this.radius = radius;
        }

        double area() {
            // TODO: implement
            return 0;
        }

        @Override
        String describe() {
            // TODO: implement using super.describe()
            return null;
        }
    }

    static class Square extends Shape {
        double side;

        Square(String color, double side) {
            super(color); // provided — must be the first statement
            // TODO: assign this.side = side;
        }

        double area() {
            // TODO: implement
            return 0;
        }

        @Override
        String describe() {
            // TODO: implement using super.describe()
            return null;
        }
    }

    // --- self-check: do not modify below this line ---
    public static void main(String[] args) {
        boolean ok = true;

        Circle c = new Circle("red", 2.0);
        ok &= c.color.equals("red");
        ok &= Math.abs(c.area() - (Math.PI * 4)) < 0.0001;
        ok &= c.describe().equals("A red shape (circle, area=" + c.area() + ")");

        Square s = new Square("blue", 3.0);
        ok &= s.area() == 9.0;
        ok &= s.describe().equals("A blue shape (square, area=9.0)");

        // polymorphism: declared as Shape, but override still runs
        Shape shapeRef = c;
        ok &= shapeRef.describe().equals(c.describe());

        System.out.println(ok ? "PASS" : "FAIL");
    }
}
