2022-05-03 13:49:39 +03:00
|
|
|
const dis_big = document.getElementById("dis_big");
|
|
|
|
const dis_sml = document.getElementById("dis_sml");
|
2022-05-02 23:00:58 +03:00
|
|
|
|
2022-05-03 13:49:39 +03:00
|
|
|
const calc = new Calculator();
|
|
|
|
|
|
|
|
const buttons = document.querySelector('.buttons');
|
|
|
|
buttons.addEventListener('click', e => {
|
|
|
|
const value = e.target.value;
|
|
|
|
PressButton(value);
|
|
|
|
})
|
|
|
|
|
|
|
|
function PressButton(button) {
|
|
|
|
calc.pressbutton(button);
|
|
|
|
|
|
|
|
tmp = '';
|
|
|
|
switch (calc.operator) {
|
|
|
|
case 'ADD':
|
|
|
|
tmp = ' +';
|
|
|
|
break;
|
|
|
|
case 'SUB':
|
|
|
|
tmp = ' -';
|
|
|
|
break;
|
|
|
|
case 'MUL':
|
|
|
|
tmp = ' *';
|
|
|
|
break;
|
|
|
|
case 'DIV':
|
|
|
|
tmp = ' /';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
console.log('Invalid operator');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
dis_big.innerText = calc.curr;
|
|
|
|
dis_sml.innerText = calc.prew + tmp;
|
|
|
|
}
|