Getters / Setters

In actual implementation, all attributes should be private. Attributes are read and set with getter and setter methods.

Different notations: ObjC and Java Notation.

Setter: Both: add "set", capitalize attribute, e.g. color -> setColor()

Getter: Java (to use in this class), add "get", capitalize attribute, e.g. color -> getColor().

ObjC (just fyi): use the same name as the attribute, OR use "is" prefix in case of booleans, e.g. : color -> color(), bw -> isBw()

Read-Only attributes: have no "setter"

Figure 3.2. Example of the same attributes, with getters and setters
Example of the same attributes, with getters and setters

Practice: do the same thing (bomb), now with getters and setters.

Figure 3.3. Excerpt from the atomic bomb, now with getters and setters
Excerpt from the atomic bomb, now with getters and setters

No matter which notation you use, in the actual implementation you should always user getters / setters to do the implementation hiding!