Esempio n. 1
0
nt main(void)
{
    string select;
      WorldClock worldClock;
        
        while(true)
            {
                  cin>>select;
                      if(select=="set")
                            {
                                    try{
                                              cin>>worldClock;
                                                      cout<<worldClock<<endl;
                                                            }catch(InvalidTimeException iserr)
                                          {
                                                    cout<<"Invalid time: "<<iserr.input_time<<endl;
                                                          }
                                              }
                          else if(select=="tick")
                                {
                                        int second;
                                              cin>>second;
                                                    worldClock.Tick(second);
                                                          cout<<worldClock<<endl;
                                                              }
Esempio n. 2
0
ostream& operator<<(ostream& os, const WorldClock& c)
{
	WorldClock temp = c;
	temp.Tick(temp.time_difference()*secondOfTime);

	os << temp.hour() << ":" << temp.minute() << ":" << temp.second();
	if (temp.time_difference() >= 0)	os << " (+" << temp.time_difference() << ")";
	else os << " (" << temp.time_difference() << ")";
	return os;
}
Esempio n. 3
0
int main() {
  WorldClock clock; 
  string cmd;
  while (cmd != "quit") {
    cin >> cmd;
    try {
      if (cmd == "set") {
        cin >> clock;
        cout << clock << endl;
      } else if (cmd == "tick") {
        int tick = 1;
        cin >> tick;
        clock.Tick(tick);
        cout << clock << endl;
      } else if (cmd == "set_timezone") {