From 667c20bf45081baf028129b9f1e62f8c15d4fa4c Mon Sep 17 00:00:00 2001 From: dev Date: Sat, 1 Jun 2019 23:45:07 -0500 Subject: [PATCH] avance-bd --- sesion3/index.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 sesion3/index.js diff --git a/sesion3/index.js b/sesion3/index.js new file mode 100644 index 0000000..e8de8ca --- /dev/null +++ b/sesion3/index.js @@ -0,0 +1,40 @@ +class User { + constructor(name, email, age) { + this.name = name; + this.email = email; + this.age = age; + } +} + +class Song { + constructor(category, author, title) { + this.category = category; + this.author = author; + this.title = title; + } +} + +class Playlist { + constructor(title) { + this.title = title; + this.playlist = {}; + } +} + +Playlist.prototype.add = function (id, playlist) { + this.playlist[id] = playlist; +} + +Playlist.prototype.remove = function (id) { + delete this.playlist[id]; +} + +let s = new Song('cat1', 'Author1', 'title1'); +let t = new Song('cat2', 'Author2', 'title2'); + +let r = new Playlist('miscelanea'); + +r.add(12, s); +r.add(15, t); +r.remove(12); +console.log(r);