Math-Practice/Problem.h

57 lines
1.2 KiB
C
Raw Normal View History

2019-03-31 18:40:37 -04:00
#ifndef DVEREB_PROBLEM_H
#define DVEREB_PROBLEM_H
#include <string>
2019-03-31 18:40:37 -04:00
#include <cstdlib>
#include <ncurses.h>
enum PROBLEM_TYPE
{
// NOTE(dev): EASY means each digit can be handled without carryover.
// e.g. 33 + 46 is easy because 3+6 < 10 and 3+4 is < 10.
2019-03-31 18:40:37 -04:00
// HARD means you might have to carry over.
// e.g. 33 + 97 is hard because 7 + 3 = 10, carry the 1, 9 + 3 + 1 = 13, 130.
EASY_ADDITION = 1,
EASY_SUBTRACTION,
HARD_ADDITION,
HARD_SUBTRACTION,
};
enum INPUT_STYLE
{
INPUT_PREPEND = 1,
INPUT_APPEND,
};
2019-03-31 18:40:37 -04:00
class Problem
{
public:
Problem(PROBLEM_TYPE type, unsigned short max_digits, unsigned win_x, unsigned win_y);
~Problem();
void Draw(bool selected);
void Input(char character);
bool Correct() const;
2019-03-31 18:40:37 -04:00
private:
Problem() = delete;
static bool seeded;
PROBLEM_TYPE problem_type;
WINDOW *win = nullptr;
unsigned window_x, window_y;
int number_top;
int number_bottom;
INPUT_STYLE input_style = INPUT_STYLE::INPUT_PREPEND;
int Input() const;
std::string input;
2019-03-31 18:40:37 -04:00
// Helper Functions:
void GenerateNumbers(PROBLEM_TYPE type, unsigned short max_digits);
void GenerateWindow(unsigned win_x, unsigned win_y);
};
#endif