// Una clase con constructor, campos privados, métodos const y una referencia devuelta.
#include <cassert>
#include <iostream>
#include <string>

class Course {
public:
    Course(const std::string& name, int credits) : name_(name), credits_(credits) {
        assert(credits > 0);
    }

    void enroll() {
        enrolled_++;
    }

    int enrolled() const {
        return enrolled_;
    }

    int credits() const {
        return credits_;
    }

    // Devuelve el nombre sin copiarlo. La referencia es del objeto y vive lo que él.
    const std::string& name() const {
        return name_;
    }

    // private es por clase: este método puede ver los campos de other.
    bool same_credits_as(const Course& other) const {
        return credits_ == other.credits_;
    }

private:
    std::string name_;
    int credits_;
    int enrolled_ = 0;
};

void print_summary(const Course& course) {
    std::cout << course.name() << ": " << course.credits() << " créditos, "
              << course.enrolled() << " matriculados\n";
}

int main() {
    Course data("Estructuras de Datos", 4);
    Course math("Matemática Discreta", 4);
    data.enroll();
    data.enroll();
    print_summary(data);
    print_summary(math);
    std::cout << "mismos créditos: " << data.same_credits_as(math) << "\n";
    return 0;
}
