Advertisement
pacho_the_python

Untitled

Dec 19th, 2022
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. from band import Band
  2. from band_members.drummer import Drummer
  3. from band_members.guitarist import Guitarist
  4. from band_members.singer import Singer
  5.  
  6.  
  7. class ConcertTrackerApp:
  8. bands = []
  9. musicians = []
  10. concerts = []
  11.  
  12. def create_musician(self, musician_type: str, name: str, age: int):
  13. musician_types = ["Guitarist", "Drummer", "Singer"]
  14. if musician_type not in musician_types:
  15. raise ValueError("Invalid musician type!")
  16.  
  17. for musician in self.musicians:
  18. if musician.name == name:
  19. raise Exception(f"{name} is already a musician!")
  20.  
  21. if musician_type == 'Guitarist':
  22. new_musician = Guitarist(name, age)
  23. self.musicians.append(new_musician)
  24. elif musician_type == 'Drummer':
  25. new_musician = Drummer(name, age)
  26. self.musicians.append(new_musician)
  27. elif musician_type == "Singer":
  28. new_musician = Singer(name, age)
  29. self.musicians.append(new_musician)
  30.  
  31. return f"{name} is now a {musician_type}."
  32.  
  33. def create_band(self, name: str):
  34. for band in self.bands:
  35. if band.name == name:
  36. raise Exception(f"{name} band is already created!")
  37. new_band = Band(name)
  38. self.bands.append(new_band)
  39. return f"{name} was created."
  40.  
  41. def create_concert(self, genre: str, audience: int, ticket_price: float, expenses: float, place: str):
  42. pass
  43.  
  44. def add_musician_to_band(self, musician_name: str, band_name: str):
  45. current_musicians = []
  46. current_bands = []
  47. for musician in self.musicians:
  48. current_musicians.append(musician.name)
  49. if musician_name not in current_musicians:
  50. raise Exception(f"{musician_name} isn't a musician!")
  51.  
  52. for band in self.bands:
  53. current_bands.append(band.name)
  54. if band_name not in current_bands:
  55. raise Exception(f"{band_name} isn't a band!")
  56.  
  57. for player in self.musicians:
  58. if player.name == musician_name:
  59. self.bands.append(player)
  60. return f"{musician_name} was added to {band_name}."
  61.  
  62. def remove_musician_from_band(self, musician_name: str, band_name: str):
  63. pass
  64.  
  65. def start_concert(self, concert_place: str, band_name: str):
  66. pass
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement