#include "StopWatch.h"
#include <iomanip>
StopWatch::StopWatch() : seconds_(0)
{
}
StopWatch::StopWatch(int seconds) : seconds_(seconds)
{
}
void StopWatch::Increment(int seconds)
{
seconds_ += seconds;
}
int StopWatch::GetSeconds() const
{
return seconds_;
}
void StopWatch::Reset()
{
seconds_ = 0;
}
std::ostream& operator<<(std::ostream &os, const StopWatch &sw)
{
int hours, minutes, seconds;
hours = sw.seconds_ / 3600;
minutes = (sw.seconds_ - (hours * 3600)) / 60;
seconds = sw.seconds_ % 60;
os.fill('0');
os << std::setw(2) << hours << ':';
os << std::setw(2) << minutes << ':';
os << std::setw(2) << seconds << std::endl;
return os;
}