Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. /* 8-Create a DownloadableMovie that extends from Movie adding a download method.
  2. Here you will have to set the correct prototype to DownloadableMovie.
  3. */
  4.  
  5. var Movie = (function () {
  6.  
  7. var movieTitle ="",
  8. attr = new Map();
  9.  
  10. var constructor = function(title) {
  11. movieTitle = title;
  12. console.log(title);
  13. };
  14. var set = function (key, value){
  15. attr.set(key, value);
  16. };
  17. var stop = function(){
  18. console.log(movieTitle + "Stopped");
  19. };
  20. var play = function(){
  21. console.log("Playing" + movieTitle);
  22. };
  23. var get = function(key){
  24. alert(attr.get(key));
  25. return(attr.get(key));
  26. };
  27. var showAttributes = function(){
  28. for (var [key, value] of attr) {
  29. console.log(key + " = " + value);
  30. }
  31. console.log(movieTitle);
  32. };
  33.  
  34. return {
  35. constructor:constructor,
  36. set:set,
  37. play:play,
  38. stop:stop,
  39. get:get,
  40. showAttributes:showAttributes
  41. };
  42.  
  43. } )();
  44.  
  45.  
  46. var DownloadableMovie = function () {
  47. // calling to constructor root
  48. Movie.call(this, title);
  49.  
  50. var download = function() {
  51. console.log(title + "is downloading");
  52. };
  53. };
  54.  
  55. // Inherits from the Person class
  56. DownloadableMovie.prototype = Object.create(Movie.prototype);
  57. //DownloadableMovie.prototype.constructor =
  58. //Object.create(Movie.prototype);
  59.  
  60.  
  61. //var Ironman = new Movie();
  62. //Ironman.constructor("Iron man");
  63. //ar Ironman = Movie.constructor("Iron man");
  64. Ironman = Movie;
  65. Ironman.constructor("The Ironman");
  66. 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.");
  67. Ironman.set("Actor", "Robert Downey Jr as Movie");
  68. Ironman.showAttributes();
  69. Ironman2 = Movie;
  70. 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. ");
  71. Ironman2.set("Actor", "Misis Pot");
  72. Pirate = DownloadableMovie;
  73. Pirate.download();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement