Advertisement
AlexzanderF

Class Laptop

Jul 7th, 2020
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Laptop {
  2.     isOn = false;
  3.     constructor(info, quality) {
  4.         this.info = info;
  5.         this.quality = quality;
  6.     }
  7.  
  8.     turnOn() {
  9.         this.isOn = true;
  10.         this.quality--;
  11.     }
  12.  
  13.     turnOff() {
  14.         this.isOn = false;
  15.         this.quality--;
  16.     }
  17.  
  18.     showInfo() {
  19.         let output = JSON.stringify(this.info);
  20.         console.log(output);
  21.     }
  22.  
  23.     get price() {
  24.         let price = (800 - (this.info.age * 2) + (this.quality * 0.5));
  25.         return price;
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement