#include "bomb.hh" #include #include Bomb::Bomb(int ticks) { if (ticks <= 0) throw std::runtime_error{ "Number of ticks should be strictly positive" }; max_ticks_ = ticks; count_ = 0; } void Bomb::tick() { if (count_ >= max_ticks_) throw std::runtime_error{ "Bomb should have already exploded." }; if (count_ % 2) std::cout << "Tac!\n"; else std::cout << "Tic!\n"; count_++; } bool Bomb::has_exploded() const { return count_ >= max_ticks_; }