Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save iamstarkov/7273341c9b4d8abbc654c6bb2e96532a to your computer and use it in GitHub Desktop.
Save iamstarkov/7273341c9b4d8abbc654c6bb2e96532a to your computer and use it in GitHub Desktop.
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