-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsole.cpp
More file actions
28 lines (24 loc) · 866 Bytes
/
Console.cpp
File metadata and controls
28 lines (24 loc) · 866 Bytes
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
#include "Console.h"
#include <iostream>
#include <ctime>
#include <iomanip>
#include <sstream>
Console::Console() : name(""), currentLine(0), totalLine(0), timestamp(getCurrentTimestamp()) {}
Console::Console(std::string name, int currentLine, int totalLine)
: name(name), currentLine(currentLine), totalLine(totalLine)
{
timestamp = getCurrentTimestamp();
}
std::string Console::getCurrentTimestamp() {
time_t now = time(0);
tm* localtm = localtime(&now);
char buffer[100];
strftime(buffer, sizeof(buffer), "%m/%d/%Y, %I:%M:%S %p", localtm);
return std::string(buffer);
}
void Console::display(int totalLine) const {
system("cls");
std::cout << "Console: " << name << std::endl;
std::cout << "Instruction: " << currentLine << " / " << totalLine << std::endl;
std::cout << "Started at: " << timestamp << std::endl;
}