Last active
August 1, 2018 22:56
-
-
Save JoseJuan81/0a5270e1d439ed529794f54a42e40162 to your computer and use it in GitHub Desktop.
JS Bin// source http://jsbin.com/vojidus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Crear un script que represente el registro de personas. | |
// Se necesita su DNI (obligatorio), nombre y edad. | |
// Asimismo el script debe contemplar la posibilidad que ciertas personas | |
// tienen unas habilidades especiales como volar, correr muy rápido y | |
// dormir duraten días. | |
class peopleData { | |
constructor(dni) { | |
if (dni) { | |
this.dni = dni; | |
this.validateDni(dni); | |
} else { | |
throw 'Se requiere el DNI del usuario'; | |
} | |
this.name = ''; | |
this.lastName = ''; | |
} | |
setName(name) { | |
this.name = name; | |
return this.name; | |
} | |
setLastName(lastname) { | |
this.lastName = lastname; | |
return lastName; | |
} | |
validateDni(dni) { | |
if (String(dni).length !== 8) { | |
throw 'El DNI debe tener 8 dígitos'; | |
} | |
} | |
} | |
class people extends peopleData{ | |
super(dni) { | |
this.skill = ''; | |
} | |
getSkills() { | |
return this.skill; | |
} | |
setSkills(sk) { | |
this.skill = sk; | |
return this.getSkills(); | |
} | |
} | |
var user1 = new people(12345678); | |
// user1.setName('jose') | |
// user2.setSkills('volar') | |
console.log( | |
'Respuesta:', | |
user1, | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment