Accessor and Mutator Methods
double width = box.getWidth();
box.translate(15, 25);
//moves the rectangle by 15
units in x-direction and 25 in y.
Accessor method
views the data of an object
while mutator method updates the data
of an object.
Think:
Look at String class.
There are three methods that we have seen.
They are length(),replace(), and toUpperCase().
Is each of them accessor or mutator?
Methods include:
1. the action that the method carries out.
2. the parameters that the method receives.
3. the value that it returns (or void - no value to
return)
of Rectangle class




