#include #include #include using namespace std; class Timer { public: int hours, minutes, seconds; Timer(int h, int m, int s) : hours(h), minutes(m), seconds(s) {} void display() const { cout << (hours < 10 ? "0" : "") << hours << ":" << (minutes < 10 ? "0" : "") << minutes << ":" << (seconds < 10 ? "0" : "") << seconds << endl; } void tick() { if (seconds > 0) { --seconds; } else { if (minutes > 0) { --minutes; seconds = 59; } else if (hours > 0) { --hours; minutes = 59; seconds = 59; } } } bool finished() const { return hours == 0 && minutes == 0 && seconds == 0; } void start() { while (!finished()) { display(); this_thread::sleep_for(chrono::seconds(1)); tick(); } cout << "Time's up!" << endl; } }; int main() { Timer timer(0, 0, 10); cout << "Starting countdown timer:\n"; timer.start(); return 0; }