Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python In this problem you will create two classes; one called Member and another called Band. Neither of these classes inherit each other this problem

python

image text in transcribed

In this problem you will create two classes; one called Member and another called Band. Neither of these classes inherit each other this problem will use a technique called composition instead of inheritance. Each Member object will contain the following information: 1. Instrument type (for example, "guitar) 2. Player name (for example, "Susan") The Member cass will also contain the following methods (other than init 1. def getInstrument (self): 2. def getPlayer (self) 3. def setInstrument (self, instrument) 4. def setPlayer (self, player) 5. def (self): This method will return the instrument type This method will return the player's name This method will set the type of instrument to the new instrument type passed in This method will set the name of the player to the new player name passed in a. a. a. a. This method retums a string representation of the Member object (for example. str (Member ("guitar", "Susan")) would return the string "Susan plays guitar") a. 6. defeq (self, rhand) : a. This method overnides the function and returns a boolean based on the equality of the self Member and rhand Member's lowered strings (Membe r ("bass"Sue"Member ("Bass", "sue") should return Each Band object will contain the following information: I. Name of the band (for example, "The Ramones") 2. List containing Member objects that make up the band The Band class will also contain the following methods (other than init. ): 1. def getBandName (self): 2. def getPlayers (self): 3. def getInstruments (self): a. This method will return the name of the band a. This method will return a list of all the players' names This method will return a dictionary containing the types of instruments as its keys and the number of them in the band as its values a. 4. def addMember(self, member): a. This method will append a new member to the band's member list 5. def removeMember (self, member) This method will remove all occurrences (not case sensitive) of the input member in the band's current member list (hint take advantage of the overridden eq method in Member!) a. 6. def str self) a This method will return a string including the name of the band and all of its members along with their instruments. See below for an example. 7. def findPlayer (self, player): a. This method will print each Member's string that has the given input player. If there are multiple Members that share a name, then they should all be printed (maintaining the capitalization of the stored names and instruments). If there are no matching players in the Band's Member objects, then print the name of the band and a note saying there are no players with the given name. See below for an example. 8. def findInst rument (self, instrument) a. This method will print each Member's string that has the given input instrument type. If there are no matching instruments in the Band's Member objects, then print the name of the band and a note saying it doesn't contain the given instrument type. See below for an example

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Query Formulation And Administration Using Oracle And PostgreSQL

Authors: Michael Mannino

8th Edition

1948426951, 978-1948426954

More Books

Students also viewed these Databases questions