#include "stdstuff.h" #include "Time.h" Time::Time () { totalSecs = 0; } Time::Time (int hrs, int mins, int secs) { if (!timeIsValid (hrs, mins, secs)) { throw invalid_argument ("Time::Time - invalid time"); } totalSecs = convertToTotalSecs (hrs, mins, secs); } Time Time::timeAfter (const Time &otherTime) const { Time result; if (otherTime.totalSecs > totalSecs) { throw invalid_argument ("Time::TimeAfter - other time is not earlier"); } result.totalSecs = totalSecs - otherTime.totalSecs; return result; } void Time::multiplyBy (double x) { if (x < 0) { throw invalid_argument ("Time::multiplyBy - invalid multiplier"); } totalSecs = (int) ((totalSecs * x) + 0.5); }