The Complete Guitar Class Hierarchy
This appendix contains the complete and final definition of the Guitar
class for guitars that we
developed in Chapter 7, Organizing Objects into Classes.
"""The guitar module implements the class hierarchy from Chapter 7.
Wooden MusicalInstrument (ABC)
| |
| +-- Clarinet (ABC)
| |
| +-- Guitar
| |
| +-- ElectricGuitar
| |
+---------------+-- AcousticGuitar
"""
from abc import ABC, abstractmethod
from enum import Enum
class MusicalInstrument(ABC):
"""Abstract base class for musical instruments.
Parameters
----------
brand : str
Manufacturer brand name. E.g., "Fender".
model : str
Instrument model name. E.g., "Stratocaster".
year_built : str
Year the instrument was built.
"""
def __init__(self, brand, model, year_built...