Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def start_concert(self, concert_place: str, band_name: str):
- band = [bands for bands in self.bands if bands.name == band_name][0]
- available_musicians = [musician for musician in band.members]
- types_musicians = ['Singer', 'Guitarist', 'Drummer']
- if not all(item in (x.__class__.__name__ for x in available_musicians) for item in types_musicians ):
- raise Exception(f"{band_name} can't start the concert because it doesn't have enough members!")
- concert = [concert for concert in self.concerts if concert.place == concert_place][0]
- played_genre = concert.genre
- available_skills = []
- for skill in [musician.skills for musician in available_musicians]:
- available_skills.extend(skill)
- needed_skills = {"Rock": ["play the drums with drumsticks", "sing high pitch notes", "play rock"],
- "Metal": ["play the drums with drumsticks", "sing low pitch notes", "play metal"],
- "Jazz": ["play the drums with drum brushes", "sing high pitch notes", "sing low pitch notes",
- "play jazz"]}
- if not set(needed_skills[played_genre]).issubset(set(available_skills)):
- raise Exception(f"The {band_name} band is not ready to play at the concert!")
- profit = (concert.audience * concert.ticket_price) - concert.expenses
- return f"{band_name} gained {profit:.2f}$ from the {concert.genre} concert in {concert_place}."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement