Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Laptop {
- info = {}
- isOn = false
- constructor(info, quality){
- this.info = {
- producer: info.producer,
- age: info.age,
- brand: info.brand
- };
- this.quality = quality;
- };
- ;
- turnOn(){
- this.quality--;
- this.isOn = true;
- // return isON
- };
- turnOff(){
- this.quality--;
- this.isOn = false;
- // return isOn;
- };
- showInfo(){
- let json = JSON.stringify(info)
- //return json;
- }
- get price(){
- return (800 - (this.info.age * 2) + (this.quality * 0.5))
- }
- }
- let info = {producer: "Dell", age: 2, brand: "XPS"}
- let laptop = new Laptop(info, 10)
- laptop.turnOn()
- console.log(laptop.showInfo())
- laptop.turnOff()
- console.log(laptop.quality)
- laptop.turnOn()
- console.log(laptop.isOn)
- console.log(laptop.price)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement