I think the setHours() etc. functions still make perfect sense. The point of this assignment is to change the data representation while still having the same interface.
You can do setHours() like this:
1 2 3 4 5
setHours(int a_hours) {
int m = getMinutes();
int s = getSeconds();
m_time = a_hours*3600 + m*60 +s;
}
SetMinutes() and setSeconds() will be similar.
addSeconds is easy: just add the number of seconds to m_time;
operator+ can be coded so it works with either data representation:
1 2 3 4 5 6
time time::operator+(int a_seconds)
{
time tmp(*this);
tmp.addSeconds(a_seconds);
return tmp;
}