From 678a57df5ca85ed8ec565e9999e9de9123b3ae36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20D=C3=ADaz=20Venero?= Date: Sat, 1 Jun 2019 20:45:30 -0500 Subject: [PATCH 1/2] autores a artistas --- .../{instrucciones.js => sesion3reto1.js} | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename Retos/sesion3-reto1/{instrucciones.js => sesion3reto1.js} (82%) diff --git a/Retos/sesion3-reto1/instrucciones.js b/Retos/sesion3-reto1/sesion3reto1.js similarity index 82% rename from Retos/sesion3-reto1/instrucciones.js rename to Retos/sesion3-reto1/sesion3reto1.js index 3e2793e..279c3f4 100644 --- a/Retos/sesion3-reto1/instrucciones.js +++ b/Retos/sesion3-reto1/sesion3reto1.js @@ -7,14 +7,13 @@ * 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 { +class Artista { constructor(nombre, pais) { this.nombre = nombre; this.pais = pais; @@ -22,10 +21,10 @@ class Autor { } class Cancion { - constructor(titulo, duracion, autor) { + constructor(titulo, duracion, artista) { this.titulo = titulo; this.duracion = duracion; - this.autor = new Autor(autor.nombre, autor.pais); + this.artista = new Artista(artista.nombre, artista.pais); } } @@ -42,8 +41,8 @@ function Spotify () { init: function () { SpotifyDB = new db([]); }, - agregarCancion: function (titulo, duracion, autor) { - SpotifyDB.canciones.push(new Cancion(titulo, duracion, autor)); + agregarCancion: function (titulo, duracion, artista) { + SpotifyDB.canciones.push(new Cancion(titulo, duracion, artista)); } } } @@ -52,6 +51,7 @@ let spotifyInstance = Spotify(); spotifyInstance.init(); +// Agregando Canciones spotifyInstance.agregarCancion('cancion uno', 4.3, {nombre: 'tanto', pais: 'tanto'}); spotifyInstance.agregarCancion('cancion dos', 4.3, {nombre: 'tanto', pais: 'tanto'}); From b14b149d36a663414e93c4b68efcf8f7c2b3e4e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20D=C3=ADaz=20Venero?= Date: Sun, 2 Jun 2019 00:13:16 -0500 Subject: [PATCH 2/2] agregar: cancion, album y playlist --- Retos/sesion3-reto1/sesion3reto1.js | 53 ++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/Retos/sesion3-reto1/sesion3reto1.js b/Retos/sesion3-reto1/sesion3reto1.js index 279c3f4..1c2308a 100644 --- a/Retos/sesion3-reto1/sesion3reto1.js +++ b/Retos/sesion3-reto1/sesion3reto1.js @@ -21,16 +21,37 @@ class Artista { } class Cancion { - constructor(titulo, duracion, artista) { + constructor(titulo, duracion, artista, album, favorito) { this.titulo = titulo; this.duracion = duracion; this.artista = new Artista(artista.nombre, artista.pais); + this.album = new Album(album.titulo); + this.favorito = favorito || false; + } +} + +class Album { + constructor(titulo, cover, ano, artista) { + this.titulo = titulo; + this.cover = cover; + this.ano = ano; + this.artista = artista + } +} + +class Playlists { + constructor(titulo, cover, author) { + this.titulo = titulo; + this.cover = cover; + this.author = author; } } class db { - constructor(canciones) { - this.canciones = canciones; + constructor(canciones, albumes, playlists) { + this.canciones = []; + this.albumes = []; + this.playlists = []; } } @@ -41,9 +62,16 @@ function Spotify () { init: function () { SpotifyDB = new db([]); }, - agregarCancion: function (titulo, duracion, artista) { - SpotifyDB.canciones.push(new Cancion(titulo, duracion, artista)); + agregarCancion: function (titulo, duracion, artista, album, favorito) { + SpotifyDB.canciones.push(new Cancion(titulo, duracion, artista, album, favorito)); + }, + agregarAlbum: function (titulo, cover, ano, artista) { + SpotifyDB.albumes.push(new Album(titulo, cover, ano, artista)); + }, + agregarPlaylists: function (titulo, cover, author) { + SpotifyDB.playlists.push(new Album(titulo, cover, author)); } + } } @@ -52,8 +80,17 @@ let spotifyInstance = Spotify(); spotifyInstance.init(); // Agregando Canciones -spotifyInstance.agregarCancion('cancion uno', 4.3, {nombre: 'tanto', pais: 'tanto'}); -spotifyInstance.agregarCancion('cancion dos', 4.3, {nombre: 'tanto', pais: 'tanto'}); +spotifyInstance.agregarCancion('La Cupula', 5.35, {nombre: 'Violadores del Verso', pais: 'EspaƱa'}, {titulo: 'Doble Vida', cover: 'url01.jpg', ano: '2003'}, true); +spotifyInstance.agregarCancion('You Would Know', 4.17, {nombre: 'Queens of Stone Age', pais: 'USA'}, {titulo: 'QOTSA', cover: 'url02.jpg', ano: '1998'}, ); +spotifyInstance.agregarCancion('I work while you are sleeping', 3.23, {nombre: 'Mount Camel', pais: 'USA'}, {titulo: 'Mount Camel', cover: 'url03.jpg', ano: '2010'}, ); +spotifyInstance.agregarCancion('Souljackert Part I', 3.13, {nombre: 'Eels', pais: 'USA'}, {titulo: 'Meet the Eels', cover: 'url04.jpg', ano: '2008'}, ); + + +// Agregar Album +spotifyInstance.agregarAlbum('QOTSA', 'url02.jpg', '1998', {nombre: 'Queens of Stone Age', pais: 'USA'} ); + +// Agregar Playlist +spotifyInstance.agregarPlaylists('Mostreo para Codear', 'urlMostreo.jpg', 'Luis Diaz Venero'); -console.log(SpotifyDB); \ No newline at end of file +console.log((JSON.stringify(SpotifyDB, null, 2))); \ No newline at end of file