-
Notifications
You must be signed in to change notification settings - Fork 0
/
product.js
38 lines (32 loc) · 851 Bytes
/
product.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
export default class Product {
constructor(code, name, amount, cost) {
this._code = code;
this._name = name;
this._amount = amount;
this._cost = cost;
}
getCode() {
return this._code;
}
getName() {
return this._name.toUpperCase();
}
getAmount() {
return this._amount;
}
getCost() {
return this._cost;
}
getTotal() {
return this.getAmount() * this.getCost();
}
dataHtml() {
return `<div>
<p>Código: ${this.getCode()}</p>
<p>Nombre: ${this.getName()}</p>
<p>Cantidad: ${this.getAmount()}</p>
<p>Costo Individual: $${this.getCost()}</p>
<p>Costo Total: $${this.getTotal()}</p>
</div>`;
}
}