en.javascript.info/1-js/8-oop/3-getters-setters/2-getter-power/solution.md
Ilya Kantor 87bf53d076 update
2014-11-16 01:40:20 +03:00

520 B

function CoffeeMachine(power, capacity) {
  //...
  this.setWaterAmount = function(amount) {
    if (amount < 0) {
      throw new Error("Значение должно быть положительным");
    }
    if (amount > capacity) {
      throw new Error("Нельзя залить воды больше, чем " + capacity);
    }

    waterAmount = amount;
  };

  this.getWaterAmount = function() {
    return waterAmount;
  };

*!*
  this.getPower = function() {
    return power;
  };
*/!*
}