JSFiddle - React, Tailwind, and code Playground
by artgas_pro
JavaScript
class CoffeeMachine {
_waterAmount = 0;
set waterAmount(value) {
if (value < 0) {alert("Отрицательное количество воды");} else {
this._waterAmount = value;
}
}
constructor(power) {
this._power = power;
}
}
// создаём новую кофеварку
let coffeeMachine = new CoffeeMachine(100);
// устанавливаем количество воды
alert(coffeeMachine.waterAmount);