-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathconstructos_example.js
More file actions
44 lines (33 loc) · 855 Bytes
/
constructos_example.js
File metadata and controls
44 lines (33 loc) · 855 Bytes
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
39
40
41
42
43
44
class Product{
#description="";
type="";
/* constructor(description, type){
this.#description=description;
this.type=type;
}
*/
constructor(description="", type){
this.#description=description;
if(type != undefined){
this.type=type;
}
}
getDescription(){
return this.#description;
}
setDescritpion(description){
this.#description=description;
}
toString(){
return this.getDescription() + `(${this.type})`;
}
}
let product= new Product();
console.log(product.toString());
product.type="Equipament";
product.setDescritpion("Silver sword");
console.log(product.toString());
product= new Product("Iron Sheild");
console.log(product.toString());
product= new Product("Potion","Item");
console.log(product.toString());