From 2d0e74d0de752a608b822e84e745125c6d0947ba Mon Sep 17 00:00:00 2001 From: "David Vereb (Home)" Date: Thu, 4 Apr 2019 06:51:04 -0500 Subject: [PATCH] WIP --- Problem.cpp | 13 +++++++++---- main.cpp | 23 +++++++++++++---------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/Problem.cpp b/Problem.cpp index f37ba51..24ab4f9 100644 --- a/Problem.cpp +++ b/Problem.cpp @@ -40,9 +40,9 @@ void Problem::Draw(bool selected, const INPUT_STYLE &input_style) // Draw the window: if(selected) - box(win, 0, 0); // 0, 0 gives default characters for the vertical and horizontal lines - // else - // box(win, ' ', ' '); + box(win, '*', '*'); // 0, 0 gives default characters for the vertical and horizontal lines + else + wborder(win, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); mvwprintw(win, 2, 4, "%'6d", number_top); mvwprintw(win, 3, 4, "%'6d", number_bottom); @@ -58,7 +58,10 @@ void Problem::Draw(bool selected, const INPUT_STYLE &input_style) break; }; mvwprintw(win, 4, 2, "========"); - mvwprintw(win, 5, 4, "%'6d", Input()); + if(Input() > 999999) + mvwprintw(win, 5, 3, " FAILED"); + else if(Input() != 0) + mvwprintw(win, 5, 3, "%'7d", Input()); // Place the cursor in the correct position! int length = input.length() + ((input.length() - 1) / 3); // add commas, too! @@ -166,6 +169,8 @@ int Problem::Input() const void Problem::Input(const INPUT_STYLE input_style, char character) { + if(input.length() > 6) + return; // TODO(dev): ASSERT if(character < '0' || character > '9') exit(-1); diff --git a/main.cpp b/main.cpp index 18393db..43b3d87 100644 --- a/main.cpp +++ b/main.cpp @@ -86,7 +86,7 @@ int main(int argc, char *argv[]) if(current_problem->Correct()) ++selected; - current_problem->Draw(true, input_style); // refresh with new input + current_problem->Draw(current_problem == *selected, input_style); // refresh with new input } for(auto *problem : problems) @@ -100,16 +100,19 @@ int main(int argc, char *argv[]) char MainMenu() { + int middle_h = COLS / 2; + int middle_v = LINES / 2; + clear(); - printw("\n"); - printw(" Welcome to Math Practice.\n"); - printw(" Please choose from the following menu:\n"); - printw(" 1. Addition\n"); - printw(" 2. Subtraction\n"); - printw(" 3. Both / Mixed\n"); - printw(" q. Quit\n"); - printw("\n"); - printw(PROMPT); + mvprintw(middle_v - 5, middle_h - 20, "\n"); + mvprintw(middle_v - 4, middle_h - 20, " Welcome to Math Practice.\n"); + mvprintw(middle_v - 3, middle_h - 20, " Please choose from the following menu:\n"); + mvprintw(middle_v - 2, middle_h - 20, " 1. Addition\n"); + mvprintw(middle_v - 1, middle_h - 20, " 2. Subtraction\n"); + mvprintw(middle_v + 0, middle_h - 20, " 3. Both / Mixed\n"); + mvprintw(middle_v + 1, middle_h - 20, " q. Quit\n"); + mvprintw(middle_v + 2, middle_h - 20, "\n"); + mvprintw(middle_v + 3, middle_h - 20, PROMPT); refresh(); return getch();