I have to add getters and setters to a class Book that looks like this :
class Book
def initialize (title, author, pages, year)
@title = title
@author = author
@pages = pages
@year = year
end
end
The problem is I am not allowed to use def
. Is it possible somehow?
The only way I know is to use:
def change_name(name)
@name = name
end
for a setter. I don't even know how a getter should look like. Any help?