Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Split = class {
- constructor(state = false, velocity = 1, temperature = 23, mode='TURBO'){
- this.state = state
- this.velocity = velocity
- this.temperature = temperature
- this.swing = false
- }
- onPower(){
- this.state = !this.state
- }
- changeTemperature(newValue) {
- if (this.state){
- if (this.temperature + newValue < 30 &&
- this.temperature + newValue > 16){
- this.temperature += newValue
- return true
- }
- return false
- }
- }
- upVelocity(){
- if ( this.velocity < 3 ){
- this.velocity++
- }
- }
- downVelocity(){
- if ( this.velocity > 1 ){
- this.velocity--
- }
- }
- pw_swing(){
- this.swing = !this.swing
- }
- display(){
- return `Split { state: ${this.state}, velocity: ${this.velocity}, temperature: ${this.temperature}, swing: ${this.swing} }`
- }
- }
- foo = new Split()
- console.log(foo)
- foo.onPower()
- console.log(foo)
- foo.changeTemperature(3)
- console.log(foo)
- foo.pw_swing()
- console.log(foo)
- foo.upVelocity()
- foo.upVelocity()
- console.log(foo)
- foo.downVelocity()
- console.log(foo)
Add Comment
Please, Sign In to add comment