To download the code, click here

01: #ifndef DMCGRATH_HEADER_HPP
02: #define DMCGRATH_HEADER_HPP
03: 
04: 
05: #include <string>
06: 
07: 
08: struct pair{
09:         int a;
10:         int b;
11: };
12: 
13: class watch{
14: 
15: protected:
16:         int minutes;
17:         int hours;
18:         int seconds;
19:         
20:         std::string alarm_time;
21:         std::string date;
22:         
23: public:
24:         
25:         //constructors
26:         watch();
27:         watch(int hours);
28:         watch(int hours, int minutes);
29:         
30:         //destructors
31:         ~watch();
32:         
33:         std::string time();
34:         void set_time(int hours, int minutes, int seconds);
35:         void set_time(std::string time_string);
36:         
37:         void set_alarm(std::string alarm_time);
38:         std::string alarm();
39:         
40:         std::string get_date();
41:         
42:         friend void print(watch w);
43:         
44: };
45: 
46: void print(watch w){
47:         //print things in a pretty fashion
48:         std::cout << w.hours << std::endl;
49: }
50: 
51: watch::watch(){
52:         this->hours = 0;
53:         this->minutes = 0;
54:         this->seconds = 0;
55:         
56:         /*
57:         .
58:         .
59:         .
60:         */
61: }
62: 
63: watch::watch(int hours, int minutes, int seconds){
64:         this->hours = hours;
65:         this->minutes = minutes;
66:         this->seconds = seconds;
67:         
68:         return;
69: }
70: 
71: std::string watch::time(){
72:         std::stringstream ss;
73:         
74:         //YYYY-MM-DDTHH:MM:SS
75:         ss << this->date << "T" 
76:            << (this->hours < 10 ? "0" : "") << this->hours << ":"
77:            << (this->minutes < 10 ? "0" : "") << this->minutes << ":"
78:            << (this->seconds < 10 ? "0" : "") << this->seconds << ":";
79: 
80:         return ss.str();
81: }
82: 
83: 
84: 
85: 
86: 
87: 
88: 
89: 
90: 
91: 
92: 
93: 
94: 
95: #endif