Made last_time a private member of the ProgressBar class per code review comment.

This commit is contained in:
phdussud 2020-12-28 09:33:35 -08:00
parent 11baca9337
commit 717870e18b
2 changed files with 3 additions and 3 deletions

View File

@ -17,15 +17,14 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "time.h"
#include "progressBar.hpp" #include "progressBar.hpp"
#include "display.hpp" #include "display.hpp"
ProgressBar::ProgressBar(std::string mess, int maxValue, int progressLen): ProgressBar::ProgressBar(std::string mess, int maxValue, int progressLen):
_mess(mess), _maxValue(maxValue), _progressLen(progressLen) _mess(mess), _maxValue(maxValue), _progressLen(progressLen)
{ {
last_time = clock();
} }
static time_t last_time;
void ProgressBar::display(int value, char force) void ProgressBar::display(int value, char force)
{ {
clock_t this_time = clock(); clock_t this_time = clock();

View File

@ -17,7 +17,7 @@
#ifndef PROGRESSBARE_HPP #ifndef PROGRESSBARE_HPP
#define PROGRESSBARE_HPP #define PROGRESSBARE_HPP
#include <time.h>
#include <iostream> #include <iostream>
class ProgressBar { class ProgressBar {
@ -30,6 +30,7 @@ class ProgressBar {
std::string _mess; std::string _mess;
int _maxValue; int _maxValue;
int _progressLen; int _progressLen;
clock_t last_time; //records the time of last progress bar update
}; };
#endif #endif