Creating a superclass
Once we've come to the conclusion that books and poems share certain fundamental attributes, the attributes of all literature, we can start breaking down these classes into component parts. Our Book class, for example, has two real variables. It has a title variable and an author variable, which are attributes we associate with all literature. It also has a publisher variable and a genre variable, which may not be unique only to books and which we don't necessarily consider all forms of literature to have. So how can we exploit this knowledge? Well, we can build our Book and Poem classes so that they share their nature as pieces of literature at a fundamental level. But to make this happen, we're first going to have ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access