// Exercise 1: constructors, `this`, and constructor chaining
//
// Implement the Rectangle class below:
//   - fields: width, height (both int)
//   - Rectangle(int width, int height): sets both fields via `this`
//   - Rectangle(int side): a SQUARE — must chain to the two-arg constructor
//     with width = height = side (use this(...) as the first statement)
//   - area(): returns width * height
//   - perimeter(): returns 2 * (width + height)

public class java_oop_fundamentals_exercise_1 {

    static class Rectangle {
        int width;
        int height;

        Rectangle(int width, int height) {
            // TODO: assign fields using `this.width = width;` etc.
        }

        Rectangle(int side) {
            // TODO: chain to Rectangle(int, int) using this(side, side)
        }

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

        int perimeter() {
            // TODO: implement
            return 0;
        }
    }

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

        Rectangle r1 = new Rectangle(4, 5);
        ok &= r1.width == 4 && r1.height == 5;
        ok &= r1.area() == 20;
        ok &= r1.perimeter() == 18;

        Rectangle square = new Rectangle(6);
        ok &= square.width == 6 && square.height == 6;
        ok &= square.area() == 36;
        ok &= square.perimeter() == 24;

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