vladovip

01. Class Laptop - task from More Exercises JS Fundamentals

Apr 20th, 2021
652
153 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Laptop {
  2.    
  3.     constructor (info, quality) {
  4.      
  5.         info = {}
  6.         this.info = {
  7.           producer : producer,
  8.           age : age,
  9.           brand : brand,
  10.         };
  11.          
  12.        
  13.         this.isOn = false;
  14.  
  15.         this.turnOn = function turnOn() {
  16.             if (turnOn === true) {
  17.                 isOn = true;
  18.             } else {
  19.                 isOn = false;
  20.             }
  21.         }
  22.  
  23.         this.turnOff = function turnOff() {
  24.             if (turnOff === true) {
  25.                 isOn = false;
  26.             } else {
  27.                 isOn = true;
  28.             }
  29.         }
  30.  
  31.         this.showInfo = function showInfo(info) {
  32.             console.log(JSON.stringify(info));
  33.         }
  34.  
  35.         this.quality = function laptopQuality() {
  36.             while (quality > 0 && ((this.turnOff === true) || (this.turnOn === true))) {
  37.                 quality -= 1;
  38.             }
  39.         }
  40.         this.getterPrice = (800 - (age * 2) + (quality * 0.5));
  41.     }
  42.  
  43. }
  44.  
  45. let info = {producer: "Dell", age: 2, brand: "XPS"}
  46. let laptop = new Laptop(info, 10)
  47. laptop.turnOn()
  48. console.log(laptop.showInfo())
  49. laptop.turnOff()
  50. console.log(laptop.quality)
  51. laptop.turnOn()
  52. console.log(laptop.isOn)
  53. console.log(laptop.price)
  54.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×