JSFiddle - React, Tailwind, and code Playground

JavaScript

function Network() {
    this._elements = [];
    this.addElements = function() {
        for (var i = 0; i < arguments.length; i++) {
            this._elements.push(arguments[i]);
        }
    };
    this.getPowerProductionDuringTheDay = function() {
        var powerProduction = 0;
        for (var i = 0; i < this._elements.length; i++) {
            if (this._elements[i] instanceof PowerStation) {
                powerProduction += this._elements[i].getPowerProductionDuringTheDay();
            }
        }
        return powerProduction;
    };
    this.getPowerProductionDuringTheNight = function() {
        var powerProduction = 0;
        for (var i = 0; i < this._elements.length; i++) {
            if (this._elements[i] instanceof PowerStation) {
                powerProduction += this._elements[i].getPowerProductionDuringTheNight();
            }
        }
        return powerProduction;
    };

    this.getPowerConsumptionDuringTheDay = function() {
        var powerConsumption = 0;
        for (var i = 0; i < this._elements.length; i++) {
            if (this._elements[i] instanceof LivingHouse) {
                powerConsumption += this._elements[i].getPowerConsumptionDuringTheDay();
            }
        }
        return powerConsumption;
    };

    this.getPowerConsumptionDuringTheNight = function() {
        var powerConsumption = 0;
        for (var i = 0; i < this._elements.length; i++) {
            if (this._elements[i] instanceof LivingHouse) {
                powerConsumption += this._elements[i].getPowerConsumptionDuringTheNight();
            }
        }
        return powerConsumption;
    };

    this.getPowerExcessDuringTheDay = function() {
        return this.getPowerProductionDuringTheDay() - this.getPowerConsumptionDuringTheDay();
    };

    this.getPowerExcessDuringTheNight = function() {
        return this.getPowerProductionDuringTheNight() - this.getPowerConsumptionDuringTheNight();
    };

    this._getProfit =...