Forked from anonymous/internal-external-interface.js
Created
November 10, 2016 13:32
-
-
Save iamstarkov/7273341c9b4d8abbc654c6bb2e96532a to your computer and use it in GitHub Desktop.
This file contains 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
class CoffeeMachine { | |
constructor(power) { | |
this.power = power; | |
this.WATER_HEAT_CAPACITY = 4200; | |
this.waterAmount = 0; | |
console.log(`Создана кофемашина мощностью ${power} ватт`); | |
} | |
onReady() { | |
console.log('кофе готов!') | |
} | |
run() { | |
setTimeout(this.onReady, this.getBoilTime()); | |
} | |
getBoilTime() { | |
return this.waterAmount * this.WATER_HEAT_CAPACITY * 80 / this.power; | |
} | |
} | |
// создать кофеварку | |
const coffeeMachine1 = new CoffeeMachine(900); | |
// залить воды | |
coffeeMachine1.waterAmount = 200; | |
coffeeMachine1.run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment