Skip to content

Instantly share code, notes, and snippets.

Created November 10, 2016 13:15
Show Gist options
  • Save anonymous/61c9d739b7bc93e66dd4ffe80796fabc to your computer and use it in GitHub Desktop.
Save anonymous/61c9d739b7bc93e66dd4ffe80796fabc to your computer and use it in GitHub Desktop.
'use strict';
function CoffeeMachine(power) {
var WATER_HEAT_CAPACITY = 4200;
this.waterAmount = 0;
function onReady() {
console.log('кофе готов!')
}
this.run = function () {
setTimeout(onReady, getBoilTime());
};
var getBoilTime = function () {
return this.waterAmount * WATER_HEAT_CAPACITY * 80 / power;
}.bind(this);
console.log('Создана кофемашина мощностью ' + power + 'ватт');
}
// создать кофеварку
var coffeeMachine = new CoffeeMachine(900);
// залить воды
coffeeMachine.waterAmount = 200;
coffeeMachine.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment