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
class Pokemon { | |
#name = ""; | |
#type = "" | |
#evolutions = []; | |
constructor(name, type, evolutions) { | |
this.#name = name; | |
this.#type = type; | |
this.#evolutions = evolutions; | |
} | |
get name() { | |
return this.#name; | |
} | |
get type() { | |
return this.#type; | |
} | |
get evolutions() { | |
return this.#evolutions; | |
} | |
} | |
/* | |
para aplicar el principio de responsabilidad única | |
separamos todas las operaciones que tengan que ver | |
con acciones dentro de la base de datos. | |
*/ | |
class DataBase { | |
// Método principal | |
constructor(pokemon) {} | |
saveData() { ... } | |
findData() { ... } | |
updateData() { ... } | |
deleteData(){ ... } | |
} | |
// Creamos la instacia de la clase pokemon | |
const Eevee = new Pokemon("Eevee", "normal", ["Jolteon", "Vaporeon", "Flareon"]); | |
// pasamos los la instancia del pokemon | |
const DB = new DataBase(Eevee); | |
// creamos un nuevo registro | |
DB.saveDateDB(Eevee); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment