Methods
A class declaration can have functions that can process the data stored in an object’s attributes. Once an object gets created, a class method can be called through it. For the Book class example, let’s create a method called paperbackOrHardcover()
that returns ‘hardcover’
if the pages of the book are more than 500 and ‘paperback’
if it is less. The definition of this method and how it is called is shown below.
