Advertisement
horozov86

class_Band

Jun 28th, 2023 (edited)
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. class Band:
  2.     def __init__(self, name):
  3.         self.name = name
  4.         self.albums = []
  5.        
  6.     def add_album(self, album):
  7.         if album in self.albums:
  8.             return f"Band {self.name} already has {album.name} in their library."
  9.         self.albums.append(album):
  10.             return f"Band {self.name} has added their newest album {album.name}."
  11.            
  12.     def remove_album(self, album_name):
  13.         for album in self.albums:
  14.             if album.name == album_name:
  15.                 if self.published
  16.                     return "Album has been published. It cannot be removed."
  17.                 self.albums.remove(album)
  18.                 return f"Album {album.name} has been removed."
  19.         return f"Album {album.name} is not found."
  20.        
  21.     def details(self):
  22.         result += f"Band {self.name}\n"
  23.         for album in self.albums:
  24.             result += album.details() + "\n"
  25.         return result.strip()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement