Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. //# Crear una funcion que agregue objetos peliculas
  2. //- El objeto pelicula Debera tener ID, titulo, descripcion, aƱo, duracion, actores, director
  3. //- Debera tener metodos para editar todas sus propiedades, menos su ID, y para los actores tendra que ir agregando uno a uno
  4. function pelicula() {
  5. this.id = 0;
  6. this.titulo = "";
  7. this.descripcion = "";
  8. this.anio = 0;
  9. this.duracion = 0;
  10. this.actores = [];
  11. this.director = "";
  12. this.agregarPelicula = agregarPelicula;
  13.  
  14. this.setId = function(id){
  15. this.id = id;
  16. };
  17. this.setTitulo = function(titulo) {
  18. this.titulo = titulo;
  19. };
  20. this.setDescripcion = function(descripcion) {
  21. this.descripcion = descripcion;
  22. };
  23. this.setAnio = function(anio) {
  24. this.anio = anio;
  25. };
  26. this.setDuracion = function(duracion){
  27. this.duracion = duracion;
  28. };
  29. this.setActores = function(actor){
  30. this.actores = actor;
  31. };
  32. this.setDirector = function(director){
  33. this.director = director;
  34. };
  35.  
  36. this.getId = function() {
  37. return this.id;
  38. };
  39. this.getTitulo = function() {
  40. return this.titulo;
  41. };
  42. this.getDescripcion = function(){
  43. return this.descripcion;
  44. };
  45. this.getAnio = function(){
  46. return this.anio;
  47. };
  48. this.getDuracion = function(){
  49. return this.duracion;
  50. };
  51. this.getActores = function(){
  52. return this.actores;
  53. };
  54. this.getDirector = function(){
  55. return this.director;
  56. };
  57. }
  58.  
  59. function agregarPelicula() {
  60. var nombrePeli = prompt("Ingrese el titulo de la pelicula");
  61. var descripcion = prompt("Ingrese una breve descripcion de lo que trata la pelicula");
  62. var anio = parseInt(prompt("Ingrese el anio de la pelicula"));
  63. var duracion = prompt("Ingrese los minutos que dura la pelicula");
  64. var actores = [];
  65. var director = prompt("Ingrese el nombre del dierector");
  66. id ++;
  67. var i = 0;
  68.  
  69. this.setId(id);
  70. this.setTitulo(nombrePeli.toLowerCase());
  71. this.setDescripcion(descripcion.toLowerCase());
  72. this.setAnio(anio);
  73. this.setDuracion(duracion);
  74. this.setActores(actores);
  75. this.setDirector(director);
  76.  
  77. do {
  78. var confirmar;
  79. var nombre = prompt("Ingrese el nombre del actor");
  80. actores[i] = nombre;
  81.  
  82. confirmar = confirm("Desea agregar otro actor?");
  83. if (confirmar === true) {
  84. i++;
  85. } else {
  86. i = -1;
  87. }
  88.  
  89. } while(i !== -1);
  90.  
  91. return this;
  92. }
  93.  
  94. var id = 0;
  95. var peli1 = new pelicula();
  96. console.log(peli1.agregarPelicula());
  97. var peli2 = new pelicula();
  98. console.log(peli2.agregarPelicula());
  99. // var titulo = peli2.getTitulo();
  100. // console.log(titulo);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement