SimpleFactory with prototype

for result of a whole new operate object.

JavaScript

//base class
function Operation() {
    //private:
    this._numberA = 0.0;
    this._numberB = 0.0;
    this._result = 0.0;

		//public:
    //methods
    this.getNumberA = function() {
        return this._numberA;
    }

    this.setNumberA = function(value) {
        this._numberA = value * 1.0;
    }

    this.getNumberB = function() {
        return this._numberB;
    }

    this.setNumberB = function(value) {
        this._numberB = value * 1.0;
    }

    this.getResult = function() {
        return this._result;
    }

    this.setResult = function(value) {
        this._result = value;
    }

}

//derived class
function OperationAdd() {
    //public:
    //override method
    this.getResult = function() {
    OperationAdd.prototype.setResult(this.getNumberA() + this.getNumberB());
        return OperationAdd.prototype.getResult();
    }
}

OperationAdd.prototype = new Operation();
OperationAdd.prototype.constructor = OperationAdd;


//derived class
function OperationSub() {
    //public:
    //override method
    this.getResult = function() {
        OperationSub.prototype.setResult(this.getNumberA() - this.getNumberB());
        return OperationSub.prototype.getResult();
    }
}

OperationSub.prototype = new Operation();
OperationSub.prototype.constructor = OperationSub;


//derived class
function OperationMul() {
    //public:
    //override method
    this.getResult = function() {
        OperationMul.prototype.setResult(this.getNumberA() * this.getNumberB());
        return OperationMul.prototype.getResult();
    }
}

OperationMul.prototype = new Operation();
OperationMul.prototype.constructor = OperationMul;


//derived class
function OperationDiv() {
    //public:
    //override method
    this.getResult = function() {
        OperationDiv.prototype.setResult(this.getNumberA() / this.getNumberB());
        return OperationDiv.prototype.getResult();
    }
}

OperationDiv.prototype = new Operation();
OperationDiv.prototype.constructor =...