Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. class Nanizanka{
  2. naziv
  3. opis
  4. igralci
  5. ocena
  6. slika
  7.  
  8. constructor(naziv, opis, igralci, ocena, slika){
  9. this.naziv = naziv;
  10. this.opis = opis;
  11. this.igralci = igralci;
  12. this.ocena = ocena;
  13. this.slika = slika;
  14. }
  15.  
  16. Izpis1(){
  17. console.log(this.naziv + "\t" + this.ocena);
  18. }
  19.  
  20. Izpis2(){
  21. console.log("Opis nanizanke " + this.naziv + "("+ this.ocena + "):" + this.opis + ". Igrajo: ");
  22. var i;
  23. for(i in this.igralci){
  24. console.log(this.igralci[i] + "\;");
  25. }
  26. }
  27. }
  28. var Serija1 = new Nanizanka ("The big bang theory", "A gruop of very smart friends", ["Emilia clarke", "Jim parsons", "Stan lee"], 5, "Imdb");
  29. var Serija2 = new Nanizanka ("Game of thrones", "Best hbo series", ["Emilia clarke", "Maise wiliams", "Jason Momoa"], 4.4, "HBO");
  30. var Serija3 = new Nanizanka ("Viking", "best vikings series", ["Jason Momoa", "Dean Halle", "George Washinton"], 5, "Vikings");
  31.  
  32. var nanizanke = {
  33. Nanizanke : [],
  34. dodaj : function (nanizanka){
  35. if (nanizanka instanceof Nanizanka){
  36. this.Nanizanke.push(nanizanka);
  37. console.log("Dodano.");
  38. }
  39. else{
  40. throw console.error("Neuspešno dodajanje.");
  41. }
  42. },
  43. Izpisi : function(){
  44. var i;
  45. for (i in this.Nanizanke){
  46. console.log(this.Nanizanke[i]);
  47. }
  48. },
  49. Brisi : function(indeks){
  50. if(typeof(indeks) == 'number' && this.Nanizanke[indeks] != null){
  51. this.Nanizanke.splice(indeks, 1);
  52. console.log("Izbrisano.");
  53. }
  54. else{
  55. throw console.error("Niste vnesli pravilnega indeksa.");
  56. }
  57. },
  58. IsciPoIgralcu : function(delno){
  59. var polje=[];
  60. polje.push(delno);
  61. for(var i=0;i<this.Nanizanke.length;i++){
  62. for(var y=0;y<this.Nanizanke[i].igralci.length;y++){
  63. if(this.Nanizanke[i].igralci[y]==delno){
  64. polje.push(this.Nanizanke[i]);
  65. }
  66. }
  67. }
  68. return polje;
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement