From a9d00b049bd46af103d37231886ac00e695a34fc Mon Sep 17 00:00:00 2001 From: Luis Suarez Date: Thu, 30 May 2019 23:04:20 -0500 Subject: [PATCH] sesion3-reto-1 --- Retos/sesion3-reto1/instrucciones.js | 59 ++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Retos/sesion3-reto1/instrucciones.js diff --git a/Retos/sesion3-reto1/instrucciones.js b/Retos/sesion3-reto1/instrucciones.js new file mode 100644 index 0000000..3e2793e --- /dev/null +++ b/Retos/sesion3-reto1/instrucciones.js @@ -0,0 +1,59 @@ +/** + * + * Conceptos para revisar: + * + * Factory Pattern + * ES6 Classes + * JS Modules + * + * Objetivo del Reto: Crear estructuras de datos con sus respectivos CRUD para simular un backend de Spotify o Netflix. + * + * La cantidad y complejidad de las estructuras de datos es libre. + * + * */ + +// Codigo Referencia + +class Autor { + constructor(nombre, pais) { + this.nombre = nombre; + this.pais = pais; + } +} + +class Cancion { + constructor(titulo, duracion, autor) { + this.titulo = titulo; + this.duracion = duracion; + this.autor = new Autor(autor.nombre, autor.pais); + } +} + +class db { + constructor(canciones) { + this.canciones = canciones; + } +} + +let SpotifyDB; + +function Spotify () { + return { + init: function () { + SpotifyDB = new db([]); + }, + agregarCancion: function (titulo, duracion, autor) { + SpotifyDB.canciones.push(new Cancion(titulo, duracion, autor)); + } + } +} + +let spotifyInstance = Spotify(); + +spotifyInstance.init(); + +spotifyInstance.agregarCancion('cancion uno', 4.3, {nombre: 'tanto', pais: 'tanto'}); +spotifyInstance.agregarCancion('cancion dos', 4.3, {nombre: 'tanto', pais: 'tanto'}); + + +console.log(SpotifyDB); \ No newline at end of file