-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCLIClock.cpp
More file actions
60 lines (49 loc) · 1.35 KB
/
Copy pathCLIClock.cpp
File metadata and controls
60 lines (49 loc) · 1.35 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
/*
* CLIClock.cpp
*
* Displays the clock in the command line like this (12:35):
* ---------------|12--|35------------
*
* Created on: 2014.01.09.
* Author: istvan_vig
*/
#include "CLIClock.h"
CLIClock::CLIClock() :
m_timeline_len(70),
m_hour_place(0),
m_minute_place(0),
m_second_place(0) {
;
}
CLIClock::~CLIClock() {
;
}
void CLIClock::show() {
this->m_hour_place = this->m_hour_position * this->m_timeline_len;
this->m_minute_place = this->m_minute_position * this->m_timeline_len;
this->m_second_place = this->m_second_position * this->m_timeline_len;
//std::cout << this->m_hour_position << ":" << this->m_minute_position << std::endl;
//std::cout << "Hour place: " << this->m_hour_place << ", minute place: " << this->m_minute_place << std::endl;
std::ostringstream oo;
bool show_separator = true;
for(int i=0; i<=this->m_timeline_len; i++) {
if(i==this->m_hour_place) {
oo << "H" << this->m_hour;
show_separator = false;
}
if(i==this->m_minute_place) {
oo << "M" << this->m_min;
show_separator = false;
}
if(i==this->m_second_place) {
oo << "S" << this->m_sec;
show_separator = false;
}
if (show_separator) oo << "-";
show_separator = true;
}
std::cout << "\r" << oo.str();
}
void CLIClock::setTimelineLen(int l) {
this->m_timeline_len = l;
}