const Computer = function (name, brand, model, ean) {
this.name = name;
this.brand = brand;
this.model = model;
this.ean = ean;
};
Computer.prototype.display = function () {
const item = document.querySelector("main");
const card = document.createElement("ul");
const name = document.createElement("li");
const brand = document.createElement("li");
const model = document.createElement("li");
const ean = document.createElement("li");
name.innerHTML = this.name;
brand.innerHTML = this.brand;
model.innerHTML = this.model;
ean.innerHTML = this.ean;
card.appendChild(name);
card.appendChild(model);
card.appendChild(brand);
card.appendChild(ean);
item.appendChild(card);
card.classList.add("list2");
};
Computer.prototype.addClass = function () {
const item = document.querySelector(".list2");
for(let i = 0; i < 4; i++){
item.children[i].classList.add("list-item")
}
};
const Laptop = function (name, brand, model, ean, processor, ram, hdd, gpu) {
Computer.call(this, name, brand, model, ean);
this.processor = processor;
this.ram = ram;
this.hdd = hdd;
this.gpu = gpu;
};
const Desktop = function (name, brand, model, ean, processor, ram, hdd, gpu) {
Computer.call(this, name, brand, model, ean);
this.processor = processor;
this.ram = ram;
this.hdd = hdd;
this.gpu = gpu;
};
Desktop.prototype = Object.create(Computer.prototype);
Laptop.prototype = Object.create(Computer.prototype);
const altos = new Desktop("Altos", "Gigatron", "Fighter", 46587921);
const pavilion = new Laptop("Pavilion ", "Hewlet Packard", "E345-32", 59874252);
altos.display();
pavilion.display();
altos.addClass()
pavilion.addClass()