Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* 8-Create a DownloadableMovie that extends from Movie adding a download method.
- Here you will have to set the correct prototype to DownloadableMovie.
- */
- var Movie = (function () {
- var movieTitle ="",
- attr = new Map();
- var constructor = function(title) {
- movieTitle = title;
- console.log(title);
- };
- var set = function (key, value){
- attr.set(key, value);
- };
- var stop = function(){
- console.log(movieTitle + "Stopped");
- };
- var play = function(){
- console.log("Playing" + movieTitle);
- };
- var get = function(key){
- alert(attr.get(key));
- return(attr.get(key));
- };
- var showAttributes = function(){
- for (var [key, value] of attr) {
- console.log(key + " = " + value);
- }
- console.log(movieTitle);
- };
- return {
- constructor:constructor,
- set:set,
- play:play,
- stop:stop,
- get:get,
- showAttributes:showAttributes
- };
- } )();
- var DownloadableMovie = function () {
- // calling to constructor root
- Movie.call(this, title);
- var download = function() {
- console.log(title + "is downloading");
- };
- };
- // Inherits from the Person class
- DownloadableMovie.prototype = Object.create(Movie.prototype);
- //DownloadableMovie.prototype.constructor =
- //Object.create(Movie.prototype);
- //var Ironman = new Movie();
- //Ironman.constructor("Iron man");
- //ar Ironman = Movie.constructor("Iron man");
- Ironman = Movie;
- Ironman.constructor("The Ironman");
- Ironman.set("Plot", "After being held captive in an Afghan cave, billionaire engineer Tony Stark creates a unique weaponized suit of armor to fight evil.");
- Ironman.set("Actor", "Robert Downey Jr as Movie");
- Ironman.showAttributes();
- Ironman2 = Movie;
- Ironman2.set("Plot", "When Tony Stark's world is torn apart by a formidable terrorist called the Mandarin, he starts an odyssey of rebuilding and retribution. ");
- Ironman2.set("Actor", "Misis Pot");
- Pirate = DownloadableMovie;
- Pirate.download();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement