Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Band Now, write the missing Band class that my_band.py uses. Band has Musicians in much the same way that Musician has Guitars (association). Here's what
Band
Now, write the missing Band class that my_band.py uses.
"Band has Musicians" in much the same way that "Musician has Guitars" (association). Here's what you should see when your Band class is correct:
band (str) Extreme (Nuno Bettencourt ([Washburn N4 (1990) : $2,499.95, Takamine acoustic (1986) : $1,200.00]), Gary Cherone ([]), Pat Badger ([Mouradian CS-74 Bass (2009) : $1,500.00]), Kevin Figueiredo ([])) band.play() Nuno Bettencourt is playing: Washburn N4 (1990) : $2,499.95 Gary Cherone needs an instrument! Pat Badger is playing: Mouradian CS-74 Bass (2009) : $1,500.00 Kevin Figueiredo needs an instrument!
There are plenty of fun extension exercises in this prac, including one to use inheritance with this example by creating different "types" of Musician, like "Guitarist is a Musician" and "Drummer is a Musician" (well, a drummer hangs around with musicians)
"""Band example with list of musicians.""" from band import Band from musician import Musician from guitar import Guitar def main(): band = Band("Extreme") nuno = Musician("Nuno Bettencourt") nuno.add(Guitar("Washburn N4", 1990, 2499.95)) nuno.add(Guitar("Takamine acoustic", 1986, 1200.0)) band.add(nuno) band.add(Musician("Gary Cherone")) pat = Musician("Pat Badger") pat.add(Guitar("Mouradian CS-74 Bass", 2009, 1500.0)) band.add(pat) kevin = Musician("Kevin Figueiredo") band.add(kevin) print("band (str)") print(band) print("band.play()") print(band.play()) main()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started