forked from msbomrel/exception_handle
/
main.cpp
43 lines (33 loc) · 1.15 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>
#include "MyTime.h"
#include "OutOfRangeException.h"
using namespace std;
int main()
{
int hour,minute,second;
MyTime time;
while(cout << "Enter time in format HH:MM:SS ")
{
cin>>hour>>minute>>second;
try
{
time.setTime(hour,minute,second);
break;
}
catch (OutOfRangeException &OutOfRangeException){
cout << "Exception Occured !!! " << OutOfRangeException.what() << endl;
}
}
time.nextSecond();
cout << "After one second, time is -> " << time.toString() << endl;
time.nextMinute();
cout << "After one minute, time is -> " << time.toString() << endl;
time.nextHour();
cout << "After one hour, time is -> " << time.toString() << endl;
time.previousSecond();
cout << "Before one second, time was -> " << time.toString() << endl;
time.previousMinute();
cout << "Before one minute, time was -> " << time.toString() << endl;
time.previousHour();
cout << "Before one hour, time was -> " << time.toString() << endl;
}