Advertisement
maxim_shlyahtin

5.2

Oct 31st, 2020
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.13 KB | None | 0 0
  1. class Genre:
  2.     def __init__(self, genre):
  3.         self.genre = genre
  4.  
  5.     def __str__(self):
  6.         return f'{self.genre}'
  7.  
  8.  
  9. class Band:
  10.     def __init__(self, title):
  11.         self.title = title
  12.  
  13.     def __str__(self):
  14.         return f'{self.title}'
  15.  
  16.  
  17. class Song(Genre, Band):
  18.     def __init__(self, name, genre, title):
  19.         super().__init__(genre)
  20.         self.title = title
  21.         self.name = name
  22.  
  23.     def get_g(self):
  24.         return self.genre
  25.  
  26.     def get_t(self):
  27.         return self.title
  28.  
  29.     def __str__(self):
  30.         return f'{self.name}'
  31.  
  32.  
  33. class Album:
  34.     def __init__(self, album, *name):
  35.         self.album = album
  36.         self.storage = list(name)
  37.  
  38.     def __len__(self):
  39.         return len(self.storage)
  40.  
  41.     def __getitem__(self, item):
  42.         return self.storage[item]
  43.  
  44.     def __str__(self):
  45.         a = [f'{self.storage[i]}' for i in range(len(self.storage))]
  46.         return f'{self.album}:\n' + '\n'.join(a)
  47.  
  48.  
  49. class Subgenre:
  50.     pass
  51.  
  52.  
  53. class Catalog:
  54.     def __init__(self, teg, *catalog):
  55.         self.list = catalog
  56.         self.teg = teg
  57.  
  58.     def __getitem__(self, item):
  59.         return self.list[item]
  60.  
  61.     def get_artist(self, other):
  62.         for i in range(len(self.list)):
  63.             if str(self.list[i].get_t()) == str(other):
  64.                 print(self.list[i])
  65.  
  66.     def get_genre(self, other):
  67.         for i in range(len(self.list)):
  68.             if str(self.list[i].get_g()) == str(other):
  69.                 print(self.list[i])
  70.  
  71.     def __str__(self):
  72.         a = [f'{self.list[i]}' for i in range(len(self.list))]
  73.         return f'{self.teg} -> \n' + ',\n'.join(a)
  74.  
  75.  
  76. pop = Genre('pop')
  77. rammstein = Band('rammstein')
  78. beatles = Band('beatles')
  79. L = Band('L')
  80. rok = Genre('rok')
  81. rap = Genre('rap')
  82. song, song2, song3 = Song('Senschut', rok, rammstein), Song('Circles', rap, L), Song('Rammstein', rok, rammstein)
  83. s, s2, s3 = Song('Yesterday', rok, beatles), Song('Yellow Submarine', rok, beatles), Song('Ultimate', rap, L)
  84. nice = Album('nice', song, song2)
  85. good = Album('good', s, s2)
  86. catalog = Catalog('GoodTaste', song, song2, song3, s3, s, s2)
  87. print(catalog)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement