Example #1
0
void Task36::Perform() {
  if (!ifs_.is_open()) {
    stringstream message;
    message << "Task36::Perform() : class instance hasn't been "
      << "initialized yet, invoke Initialize() before." << endl;
    throw logic_error(message.str());
  }

  MessagesSorter messages_sorter;

  Message message;
  message.ReadFrom(ifs_);
  while (!ifs_.eof()) {
    try {
      message.CalculateDays();
      messages_sorter.PutMessage(message);
    } catch (exception& ex) { 
      cerr << "Task36::Perform - exception has been caught " 
          << "reason: " << ex.what() << endl;
    }
    
    message.ReadFrom(ifs_);
  }

  messages_sorter.DumpMessages();
}