July 2011
Intermediate to advanced
400 pages
8h 46m
English
Although the classes in this would-be adventure game work well enough, they are still fairly verbose because of all those get and set accessors. Let’s see what you can do to remedy this.
Instead of accessing the value of the @description instance variable with two different methods, get_description and set_description, like this:
puts( t1.get_description )
t1.set_description("Some description" )it would be so much nicer to retrieve and assign values just as you would retrieve and assign values to and from a simple variable, like this:
puts( t1.description ) t1.description = "Some description"
To be able to do this, you need to modify the Treasure class definition. One way of accomplishing this would be to rewrite the accessor methods ...
Read now
Unlock full access