Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Laptop {
- constructor(info, quality) {
- this.info = info;
- this.quality = quality; // quality is a number
- }
- isOn = false;
- turnOn(isOn) {
- if (isOn == false) {
- isOn = true;
- return isOn;
- }
- }
- turnOff(isOn) {
- if (isOn === true) {
- isOn = false;
- return isOn;
- }
- }
- showInfo() {
- let textJSON = JSON.stringify(this.info);
- console.log(textJSON);
- } // This method works!
- quality() {
- let currentQuality = this.quality;
- while (currentQuality > 0) { {
- currentQuality--;
- }
- }
- return currentQuality;
- }
- price() {
- let currentPrice = Number(800 - info.age * 2 + quality * 0.5);
- return currentPrice;
- }
- }
- 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