February 2014
Beginner
1248 pages
62h 25m
English
Time2’s get methods are called throughout the class. In particular, methods toUniversalString and toString call methods getHour, getMinute and getSecond in line 122 and lines 129–130, respectively. In each case, these methods could have accessed the class’s private data directly without calling the 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 four bytes of memory). If we made such a change, only the bodies of the methods that access the private data directly would need to change—in particular, ...
Read now
Unlock full access