-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
91 lines (78 loc) · 2.08 KB
/
main.cpp
File metadata and controls
91 lines (78 loc) · 2.08 KB
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
// Dante Lee - Project 3-1
#include <iostream>
#include <iomanip>
#include <chrono>
#include <thread>
#include <string>
#include "Clock.h"
using namespace std;
using namespace std::this_thread;
using namespace std::chrono;
// Displays options to the user
void ShowOptions() {
// Print upper border
cout << setw(26) << setfill('*') << "" << endl;
//Print options
cout << "* 1 - Add One Hour *" << endl;
cout << "* 2 - Add One Minute *" << endl;
cout << "* 3 - Add One Second *" << endl;
cout << "* 4 - Exit Program *" << endl;
// Print lower border
cout << setw(26) << setfill('*') << "" << endl;
}
// Displays interactive 12 and 24 hour clocks
int main() {
// Instantiate clock objects
Clock clock12;
Clock clock24;
int userInput = -1;
char nextChar;
// Set clock types
clock12.setType("12");
clock24.setType("24");
for (int i = 0; i < 24; ++i) {
clock12.setTime(1);
}
do {
// Clear terminal
system("clear");
// Display clocks
ShowClocks(clock12, clock24);
// Display user options
ShowOptions();
// Add 1 second
//clock12.setTime(3);
//clock24.setTime(3);
// Wait 1 second
//sleep_for(seconds(1));
// Accept user input
cin >> userInput;
// Execute user input
switch(userInput) {
// Add one hour
case 1:
clock12.setTime(1);
clock24.setTime(1);
break;
// Add one minute
case 2:
clock12.setTime(2);
clock24.setTime(2);
break;
// Add one second
case 3:
clock12.setTime(3);
clock24.setTime(3);
break;
// Exit program
case 4:
cout << "Goodbye." << endl;
break;
default:
cout << "Invalid input." << endl;
break;
}
}
while (int(userInput) != 4);
return 0;
}