Added end-of-questions screen with time elapsed.
This commit is contained in:
parent
ed001c9139
commit
baca448ea2
21
main.cpp
21
main.cpp
@ -9,6 +9,7 @@
|
|||||||
#include "Problem.h"
|
#include "Problem.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
#define PROMPT " > "
|
#define PROMPT " > "
|
||||||
|
|
||||||
@ -62,8 +63,12 @@ int main(int argc, char *argv[])
|
|||||||
if(problem)
|
if(problem)
|
||||||
problem->Draw(problem == *selected, input_style);
|
problem->Draw(problem == *selected, input_style);
|
||||||
|
|
||||||
|
// Keep track of time:
|
||||||
|
auto start_time = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
while(selected != problems.end() && *selected)
|
while(selected != problems.end() && *selected)
|
||||||
{
|
{
|
||||||
|
|
||||||
Problem *current_problem = *selected;
|
Problem *current_problem = *selected;
|
||||||
current_problem->Draw(true, input_style); // refresh with new input
|
current_problem->Draw(true, input_style); // refresh with new input
|
||||||
auto input = getch();
|
auto input = getch();
|
||||||
@ -101,6 +106,22 @@ int main(int argc, char *argv[])
|
|||||||
current_problem->Draw(current_problem == *selected, input_style); // refresh with new input
|
current_problem->Draw(current_problem == *selected, input_style); // refresh with new input
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Keep track of time:
|
||||||
|
auto end_time = std::chrono::steady_clock::now();
|
||||||
|
auto elapsed_time = std::chrono::duration_cast<std::chrono::seconds>(end_time - start_time);
|
||||||
|
int middle_h = COLS / 2;
|
||||||
|
int middle_v = LINES / 2;
|
||||||
|
clear();
|
||||||
|
mvprintw(middle_v - 1, middle_h - 10,
|
||||||
|
"Time Elapsed: %02dm %02ds\n",
|
||||||
|
elapsed_time / 60, elapsed_time % 60);
|
||||||
|
mvprintw(middle_v + 1, middle_h - 8,
|
||||||
|
"Press Q to quit.");
|
||||||
|
wrefresh(stdscr);
|
||||||
|
|
||||||
|
while(!(getch() == 'q'))
|
||||||
|
;
|
||||||
|
|
||||||
for(auto *problem : problems)
|
for(auto *problem : problems)
|
||||||
if(problem)
|
if(problem)
|
||||||
delete problem;
|
delete problem;
|
||||||
|
Loading…
Reference in New Issue
Block a user