WIP
This commit is contained in:
parent
0d10729b37
commit
2d0e74d0de
13
Problem.cpp
13
Problem.cpp
@ -40,9 +40,9 @@ void Problem::Draw(bool selected, const INPUT_STYLE &input_style)
|
|||||||
|
|
||||||
// Draw the window:
|
// Draw the window:
|
||||||
if(selected)
|
if(selected)
|
||||||
box(win, 0, 0); // 0, 0 gives default characters for the vertical and horizontal lines
|
box(win, '*', '*'); // 0, 0 gives default characters for the vertical and horizontal lines
|
||||||
// else
|
else
|
||||||
// box(win, ' ', ' ');
|
wborder(win, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
|
||||||
|
|
||||||
mvwprintw(win, 2, 4, "%'6d", number_top);
|
mvwprintw(win, 2, 4, "%'6d", number_top);
|
||||||
mvwprintw(win, 3, 4, "%'6d", number_bottom);
|
mvwprintw(win, 3, 4, "%'6d", number_bottom);
|
||||||
@ -58,7 +58,10 @@ void Problem::Draw(bool selected, const INPUT_STYLE &input_style)
|
|||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
mvwprintw(win, 4, 2, "========");
|
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!
|
// Place the cursor in the correct position!
|
||||||
int length = input.length() + ((input.length() - 1) / 3); // add commas, too!
|
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)
|
void Problem::Input(const INPUT_STYLE input_style, char character)
|
||||||
{
|
{
|
||||||
|
if(input.length() > 6)
|
||||||
|
return;
|
||||||
// TODO(dev): ASSERT
|
// TODO(dev): ASSERT
|
||||||
if(character < '0' || character > '9')
|
if(character < '0' || character > '9')
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
23
main.cpp
23
main.cpp
@ -86,7 +86,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if(current_problem->Correct())
|
if(current_problem->Correct())
|
||||||
++selected;
|
++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)
|
for(auto *problem : problems)
|
||||||
@ -100,16 +100,19 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
char MainMenu()
|
char MainMenu()
|
||||||
{
|
{
|
||||||
|
int middle_h = COLS / 2;
|
||||||
|
int middle_v = LINES / 2;
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
printw("\n");
|
mvprintw(middle_v - 5, middle_h - 20, "\n");
|
||||||
printw(" Welcome to Math Practice.\n");
|
mvprintw(middle_v - 4, middle_h - 20, " Welcome to Math Practice.\n");
|
||||||
printw(" Please choose from the following menu:\n");
|
mvprintw(middle_v - 3, middle_h - 20, " Please choose from the following menu:\n");
|
||||||
printw(" 1. Addition\n");
|
mvprintw(middle_v - 2, middle_h - 20, " 1. Addition\n");
|
||||||
printw(" 2. Subtraction\n");
|
mvprintw(middle_v - 1, middle_h - 20, " 2. Subtraction\n");
|
||||||
printw(" 3. Both / Mixed\n");
|
mvprintw(middle_v + 0, middle_h - 20, " 3. Both / Mixed\n");
|
||||||
printw(" q. Quit\n");
|
mvprintw(middle_v + 1, middle_h - 20, " q. Quit\n");
|
||||||
printw("\n");
|
mvprintw(middle_v + 2, middle_h - 20, "\n");
|
||||||
printw(PROMPT);
|
mvprintw(middle_v + 3, middle_h - 20, PROMPT);
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
return getch();
|
return getch();
|
||||||
|
Loading…
Reference in New Issue
Block a user