Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Add more inheritance and prototype chain 🌍
Browse files Browse the repository at this point in the history
  • Loading branch information
sicktastic committed Jun 1, 2016
1 parent a36ab8a commit 8b689a0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions object_oriented_javascript/playlist/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ var playlist = new Playlist();

var hereComesTheSun = new Song("Here Comes the Sun", "The Beatles", "2:54");
var walkingOnSunshine = new Song("Walking on Sunshine", "Katrina and the Wave", "3:43");
var manOfSteel = new Movie("Man of Steel", 2013, "2:23:00");

playlist.add(hereComesTheSun);
playlist.add(walkingOnSunshine);
playlist.add(manOfSteel);

var playlistElement = document.getElementById("playlist");

Expand Down
22 changes: 22 additions & 0 deletions object_oriented_javascript/playlist/movie.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function Movie(title, artist, duration) {
Media.call(this, title, duration);
this.year = year;
}

Movie.prototype = Object.create(Media.prototype);

Movie.prototype.toHTML = function() {
var htmlString = '<li';
if (this.isPlaying) {
htmlString += ' class="current"';
}
htmlString += '>';
htmlString += this.title;
htmlString += ' (';
htmlString += this.year;
htmlString += ') ';
htmlString += '<span class="duration">'
htmlString += this.duration;
htmlString += '</span></li>';
retrun htmlString;
};

0 comments on commit 8b689a0

Please sign in to comment.