export class Lecture {
    constructor(name, ects, sws) {
        this._name = name;
        this._ects = ects;
        this._sws = sws;
    }

    effortPerWeek(weeks = 15) {
        const ECTS_COST = 30;     // Wieviel Aufwand in Zeitstunden für einen ECST-Punkt
        const DS_LENGTH = 1.5;    // Stunden pro Doppelstunden
        let timeOfEcts = this._ects * ECTS_COST;
        let sumTimePerWeek = timeOfEcts / weeks;
        let lectureTimePerWeek = DS_LENGTH * (this._sws / 2);
        return sumTimePerWeek - lectureTimePerWeek;
    }

    toString() {
        return `${this._name}|${this._ects} ECTS|${this._sws} SWS`;
    }

    set sws(sws) {
        if(sws <= 0) {
            throw new RangeError("SWS must be positiv");
        }
        this._sws = sws;
    }

    get sws() {
        return this._sws;
    }

    set ects(ects) {
        if(ects <= 0) {
            throw new RangeError("ECTS must be positiv")
        }
        this._ects = ects;
    }

    get ects() {
        return this._ects;
    }

    get name() {
        return this._name;
    }
}