Write a class Time and a public class TimeOfDay. Time stores the time of day in one private field: the number of seconds since midnight (0 … 86 399). Users of the class never see this — they use:
- a constructor
Time(int h, int m, int s)(values may overflow, e.g. 25 h wraps to 1 h); getHours(),getMinutes(),getSeconds()computed from the field;addSeconds(int s)(also negative) andtick()(+1 s), wrapping around midnight;to24h()→09:05:00andto12h()→9:05:00 AM(12:xx is PM, 0:xx is 12 AM).
main reads h m s delta and prints:
Start: 23:59:59 = 11:59:59 PM
Tick: 00:00:00
After 3725 s: 01:02:05 = 1:02:05 AM