Here's the rest of the code that makes up the digital clock. The program is made up of three classes:
TheTimestamp class that can give you the current hours, minutes, and seconds.
A class called “ClockView”. This holds everything related to the visual appearance of the clock on screen.
A class called “clock” that has overall control, and is where execution starts.
For a small example like this, we could merge everything into one class, and make it a dozen lines shorter. By keeping the design elements in separate classes, you can form a better idea of how classes should be used in bigger programs and systems.
We'll start with the class that has overall control, ...