Advertisement
vladovip

01. ClassLaptopSolution_More EX

Feb 27th, 2022
1,218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Laptop {
  2.     info = {};
  3.     isOn = false;
  4.     quality = 0;
  5.     constructor(info, quality) {
  6.         this.info = {
  7.             producer: info.producer,
  8.             age: info.age,
  9.             brand: info.brand,
  10.         };
  11.         this.quality = quality;
  12.     };
  13.  
  14.     turnOn() {
  15.         this.quality--;
  16.         this.isOn = true;
  17.         return this.isOn;
  18.     };
  19.  
  20.     turnOff() {
  21.         this.quality--;
  22.         this.isOn = false;
  23.         return this.isOn;
  24.     };
  25.  
  26.     showInfo() {
  27.         return JSON.stringify({
  28.             producer: this.info.producer,
  29.             age: this.info.age,
  30.             brand: this.info.brand,
  31.         });
  32.     };
  33.  
  34.     get price() {
  35.         return 800 - (this.info.age * 2) + (this.quality * 0.5);
  36.     };
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement