-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathskills1.js
More file actions
42 lines (34 loc) · 1.19 KB
/
skills1.js
File metadata and controls
42 lines (34 loc) · 1.19 KB
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
// El nombre de la clase es totalmente arbitrario, pero deberíamos poner algo que represente lo que queremos construir o modelar
class Programador{
constructor(nombre, dni, skills) {
this.nombre = nombre
this.idCard = dni // Normalmente la propiedad de la clase y el parámetro del constructor coinciden en nombre, pero no tienen por que.
this.fechaAlta = new Date()
this.fechaBaja = undefined // No está despedido, trabaja con nosotros
this.skills = skills
}
aprender(skill) {
this.skills.push(skill)
}
despedir() {
this.fechaBaja = new Date() // para indicar que el trabajador ya no forma parte de Singushop :(
}
trabajaConNosotros() {
return !(this.fechaBaja)
}
}
class Skill {
// nombre: string, rating: number de 1 a 5
constructor(nombre, rating) {
this.nombre = nombre
this.rating = rating
}
}
let html = new Skill('html', 3)
let minion_1 = new Programador("Didac", "48045346P", [html])
minion_1.nombre = "DÍDAC" // Con accento!!
minion_1.aprender(new Skill('css', 3))
minion_1.despedir()
console.log(minion_1)
console.log(minion_1.trabajaConNosotros())
//console.log(minion_1)