{"size": 1105, "ext": "js", "max_stars_repo_path": "entrega3/P6/Ejercicio3/recursos/js/CalculadoraBasica.js", "max_stars_repo_name": "sankosk/SEW", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "entrega3/P6/Ejercicio3/recursos/js/CalculadoraBasica.js", "max_issues_repo_name": "sankosk/SEW", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "entrega3/P6/Ejercicio3/recursos/js/CalculadoraBasica.js", "max_forks_repo_name": "sankosk/SEW", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 31.5714285714, "max_line_length": 124, "alphanum_fraction": 0.5963800905}
/*
Author: Esteban Montes Morales - UO246305
Subject: SEW ~ P6-Ecmascript-Ejercicio3
Description:
  - Simple calculator made using arrow functions and approaching the <<eval>> function
*/

"use strict";
class Calculator {
    constructor(){
        this.memory = 0;
        this.addToDisplay = (input, c) => (input.value == null || input.value == "0")  ? input.value = c : input.value += c;
        this.removeFromDisplay = (input) => input.value = input.value.substring(1, input.value.length);
        this.getFromMemory = (input) => input.value = this.memory;
        this.incMemory = (input) => (this.memory == 0) ? this.memory=input.value : this.memory++;
        this.decMemory = () => (this.memory == 0) ? this.memory: this.memory--;
    }

    resetDisplays(display, result){
        display.value = 0;
        result.value = null;
    }

    calc(display, result){
        try{
            var valorAux = eval(display.value);
        }catch(err){
            var valorAux = err;
        }
        result.value = "="+valorAux;
        display.value = valorAux;
    }
}

var calc = new Calculator();