January 2014
Intermediate to advanced
736 pages
70h 43m
English
Time2’s set and get methods are called throughout the class. In particular, method setTime calls methods setHour, setMinute and setSecond in lines 47–49, and methods toUniversalString and toString call methods getHour, getMinute and getSecond in line 102 and lines 109–110, respectively. In each case, these methods could have accessed the class’s private data directly without calling the set and get methods. However, consider changing the representation of the time from three int values (requiring 12 bytes of memory) to a single int value representing the total number of seconds that have elapsed since midnight (requiring only 4 bytes of memory). If we made such a change, only ...
Read now
Unlock full access