Advertisement
bebo231312312321

Untitled

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