Created
November 10, 2016 13:15
-
-
Save anonymous/61c9d739b7bc93e66dd4ffe80796fabc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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