This repository has been archived by the owner on Oct 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TimeDriver.cpp
111 lines (101 loc) · 4.67 KB
/
TimeDriver.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Lab 1b, More Class Programming And Testing
// Programmer: Minos Park
// Editor(s) used: Sublime Text 2
// Compiler(s) used: G++
#include <iostream>
using namespace std;
#include <cassert>
#include "Time.h"
#include "Time.h" // Testing ifndef
int main()
{
// print my name and this assignment's title
cout << "Lab 1b, More Class Programming And Testing";
cout << "Programmer: Minos Park\n";
cout << "Editor(s) used: Sublime Text 2\n";
cout << "Compiler(s) used: G++\n";
cout << "File: " << __FILE__ << endl;
cout << "Complied: " << __DATE__ << " at " << __TIME__ << endl << endl;
int hour, minute, second;
Time test;
hour = 1; test.setHours(hour);
minute = 40; test.setMinutes(minute);
second = 30; test.setSeconds(second);
cout << "Hours: " << hour << "\n";
cout << "Minutes: " << minute << "\n";
cout << "Seconds: " << second << "\n";
cout << "Expected Time in Hours: 1.675\n";
cout << "Calculated Time in Hours: " << test.timeInHours() << "\n";
assert(1.675==test.timeInHours());
cout << "Expected Time in Minutes: 100.5\n";
cout << "Calculated Time in Minutes: " << test.timeInMinutes() << "\n";
assert(100.5==test.timeInMinutes());
cout << "Expected Time in Seconds: 6030\n";
cout << "Calculated Time in Seconds: " << test.timeInSeconds() << "\n\n";
assert(6030==test.timeInSeconds());
hour = 2; test.setHours(hour);
minute = 30; test.setMinutes(minute);
second = 0; test.setSeconds(second);
cout << "Hours: " << hour << "\n";
cout << "Minutes: " << minute << "\n";
cout << "Seconds: " << second << "\n";
cout << "Expected Time in Hours: 2.5\n";
cout << "Calculated Time in Hours: " << test.timeInHours() << "\n";
assert(2.5==test.timeInHours());
cout << "Expected Time in Minutes: 150\n";
cout << "Calculated Time in Minutes: " << test.timeInMinutes() << "\n";
assert(150==test.timeInMinutes());
cout << "Expected Time in Seconds: 9000\n";
cout << "Calculated Time in Seconds: " << test.timeInSeconds() << "\n\n";
assert(9000==test.timeInSeconds());
hour = 0; test.setHours(hour);
minute = 30; test.setMinutes(minute);
second = 0; test.setSeconds(second);
cout << "Hours: " << hour << "\n";
cout << "Minutes: " << minute << "\n";
cout << "Seconds: " << second << "\n";
cout << "Expected Time in Hours: 0.5\n";
cout << "Calculated Time in Hours: " << test.timeInHours() << "\n";
assert(0.5==test.timeInHours());
cout << "Expected Time in Minutes: 30\n";
cout << "Calculated Time in Minutes: " << test.timeInMinutes() << "\n";
assert(30==test.timeInMinutes());
cout << "Expected Time in Seconds: 1800\n";
cout << "Calculated Time in Seconds: " << test.timeInSeconds() << "\n\n";
assert(1800==test.timeInSeconds());
hour = 0; test.setHours(hour);
minute = 12; test.setMinutes(minute);
second = 0; test.setSeconds(second);
cout << "Hours: " << hour << "\n";
cout << "Minutes: " << minute << "\n";
cout << "Seconds: " << second << "\n";
cout << "Expected Time in Hours: 0.2\n";
cout << "Calculated Time in Hours: " << test.timeInHours() << "\n";
assert(0.2==test.timeInHours());
cout << "Expected Time in Minutes: 12\n";
cout << "Calculated Time in Minutes: " << test.timeInMinutes() << "\n";
assert(12==test.timeInMinutes());
cout << "Expected Time in Seconds: 720\n";
cout << "Calculated Time in Seconds: " << test.timeInSeconds() << "\n\n";
assert(720==test.timeInSeconds());
Time copy = test;
cout << "Calculated Time in Hours @ copy: " << copy.timeInHours() << "\n";
cout << "Calculated Time in Hours @ test: " << test.timeInHours() << "\n";
assert(copy.timeInHours()==test.timeInHours());
cout << "Calculated Time in Minutes @ copy: " << copy.timeInMinutes() << "\n";
cout << "Calculated Time in Minutes @ test: " << test.timeInMinutes() << "\n";
assert(copy.timeInMinutes()==test.timeInMinutes());
cout << "Calculated Time in Seconds @ copy: " << copy.timeInSeconds() << "\n";
cout << "Calculated Time in Seconds @ test: " << test.timeInSeconds() << "\n\n";
assert(copy.timeInSeconds()==test.timeInSeconds());
Time copy2; copy2 = test;
cout << "Calculated Time in Hours @ copy2: " << copy2.timeInHours() << "\n";
cout << "Calculated Time in Hours @ test: " << test.timeInHours() << "\n";
assert(copy2.timeInHours()==test.timeInHours());
cout << "Calculated Time in Minutes @ copy2: " << copy2.timeInMinutes() << "\n";
cout << "Calculated Time in Minutes @ test: " << test.timeInMinutes() << "\n";
assert(copy2.timeInMinutes()==test.timeInMinutes());
cout << "Calculated Time in Seconds @ copy2: " << copy2.timeInSeconds() << "\n";
cout << "Calculated Time in Seconds @ test: " << test.timeInSeconds() << "\n\n";
assert(copy2.timeInSeconds()==test.timeInSeconds());
}