Guest User

Untitled

a guest
Sep 25th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. const Split = class {
  2. constructor(state = false, velocity = 1, temperature = 23, mode='TURBO'){
  3. this.state = state
  4. this.velocity = velocity
  5. this.temperature = temperature
  6. this.swing = false
  7. }
  8.  
  9. onPower(){
  10. this.state = !this.state
  11. }
  12.  
  13. changeTemperature(newValue) {
  14. if (this.state){
  15. if (this.temperature + newValue < 30 &&
  16. this.temperature + newValue > 16){
  17. this.temperature += newValue
  18. return true
  19. }
  20. return false
  21. }
  22. }
  23.  
  24. upVelocity(){
  25. if ( this.velocity < 3 ){
  26. this.velocity++
  27. }
  28. }
  29.  
  30. downVelocity(){
  31. if ( this.velocity > 1 ){
  32. this.velocity--
  33. }
  34. }
  35.  
  36. pw_swing(){
  37. this.swing = !this.swing
  38. }
  39.  
  40. display(){
  41. return `Split { state: ${this.state}, velocity: ${this.velocity}, temperature: ${this.temperature}, swing: ${this.swing} }`
  42. }
  43.  
  44. }
  45.  
  46. foo = new Split()
  47. console.log(foo)
  48. foo.onPower()
  49. console.log(foo)
  50. foo.changeTemperature(3)
  51. console.log(foo)
  52. foo.pw_swing()
  53. console.log(foo)
  54. foo.upVelocity()
  55. foo.upVelocity()
  56. console.log(foo)
  57. foo.downVelocity()
  58. console.log(foo)
Add Comment
Please, Sign In to add comment