1: //TestStuff42.cpp
2: //Thursday, Mar 20, 2014
3:
4: #include <iostream>
5: #include <string>
6: #include <iomanip>
7: #include <cstdlib>
8: using namespace std;
9:
10: #include "utilities.h"
11: using Scobey::Pause;
12:
13: #include "time.h"
14:
15: Time add
16: (
17: const Time& t1, //in
18: const Time& t2 //in
19: )
20: {
21: Time t;
22: int originalSeconds = t1.getSeconds() + t2.getSeconds();
23: int originalMinutes = t1.getMinutes() + t2.getMinutes();
24: int originalHours = t1.getHours() + t2.getHours();
25:
26: int seconds = originalSeconds % 60;
27: int minutes = (originalMinutes + originalSeconds / 60) % 60;
28: int hours = (originalHours + originalMinutes / 60) % 24;
29: t.set(hours, minutes, seconds);
30: return t;
31: }
32:
33: int main(int argc, char* argv[])
34: {
35: //Time t1(3, 15, 30);
36: //cout << t1 << endl;
37: //Time t2(1, 3, 20);
38: //cout << t2 << endl;
39:
40: //cout << t1.operator+(t2) << endl;
41: //cout << add(t1, t2) << endl;
42: //cout << t1 + t2 << endl;
43:
44: // Time t1;
45: // Time t2(5);
46: // Time t3(5, 30);
47: // Time t4(5, 30, 10);
48:
49: // cout << "\nt1: " << t1;
50: // cout << "\nt2: " << t2;
51: // cout << "\nt3: " << t3;
52: // cout << "\nt4: " << t4;
53: // cout << endl;
54: // Pause();
55:
56:
57: //Time t;
58: //t.set(23, 59, 55);
59: //cout << "\nt: " << t;
60: //cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n');
61:
62: //cout << "\nIncrementing t:" << endl;
63: //for (int count = 1; count <= 10; count++)
64: //{
65: // cout << t;
66: // cout << ' ';
67: // t.increment();
68: // cout << endl;
69: //}
70: //cout << "Press Enter to continue ... "; cin.ignore(80, '\n');
71:
72:
73: //cout << "\nEnter a Time object value (hh:mm:ss): ";
74: //Time t20;
75: //cin >> t20; cin.ignore(80, '\n');
76: //cout << "The value entered was " << t20 << ".\n";
77: //Pause();
78:
79: //cout << "\nEnter two Time object values (hh:mm:ss), separated by "
80: // "a blank space:\n";
81: //Time t30, t31;
82: //cin >> t30 >> t31; cin.ignore(80, '\n');
83: //cout << "The values entered were " << t30 << " and " << t31 << ".";
84: //cout << "\nThese values are" << ((t30 == t31) ? " " : " not ") << "equal.";
85: //cout << "\nPress Enter to continue ... "; cin.ignore(80, '\n');
86: }