वाद्य यंत्र

आप एक संगीत ऑर्केस्ट्रा के वाद्य यंत्रों की इन्वेंटरी प्रबंधित करने के लिए एक एप्लिकेशन विकसित कर रहे हैं। आपको विभिन्न प्रकार के वाद्य यंत्रों और उनके कार्यों को मॉडल करना है।
आपसे एक MusicInstrument क्लास बनाने के लिए कहा गया है जिसमें दो एट्रिब्यूट्स हों: name और type। इस क्लास में एक मेथड play() भी होना चाहिए जो "Playing the instrument" प्रिंट करे।
फिर, MusicInstrument क्लास से इनहरिट करने वाली एक Guitar क्लास बनाएं (Guitar का type String है। इसे Guitar के __init__ में स्वचालित रूप से सेट किया जाना चाहिए)। इस क्लास में एक मेथड tune() होना चाहिए जो "Tuning the guitar" प्रिंट करे। Guitar क्लास में play() मेथड पहले tune() मेथड को कॉल करना चाहिए और फिर super() का उपयोग करके पैरेंट क्लास के play() को कॉल करना चाहिए।
Guitar क्लास की तरह ही एक Violin क्लास बनाएं (इसका type भी String है)। tune() मेथड "Tuning the violin" प्रिंट करना चाहिए।
अंत में, एक Piano क्लास बनाएं जो MusicInstrument क्लास से इनहरिट करे (Piano का type Keyboard है)। Piano क्लास को play() मेथड को ओवरराइड करना चाहिए, लेकिन इसे बजाते समय ट्यून नहीं किया जाना चाहिए।
इनपुट
आउटपुट
guitar = Guitar('Gibson'); violin = Violin('Stradivarius'); piano = Piano('Steinway'); guitar.play(); violin.play(); piano.play(); print(guitar.type); print(violin.type); print(piano.type)
Tuning the guitar Playing the instrument Tuning the violin Playing the instrument Playing the instrument String String Keyboard
नोट: वाद्य यंत्र के name और type एट्रिब्यूट्स को क्लास के कंस्ट्रक्टर में इंस्टैंशिएशन के समय पास किया जाना चाहिए। play() मेथड को बिना किसी पैरामीटर के कॉल करना चाहिए।
 

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue