Math-Practice/Problem.h

61 lines
1.3 KiB
C
Raw Permalink 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,
2020-03-10 15:52:49 -04:00
EASY_MULTIPLICATION,
EASY_DIVISION,
2019-03-31 18:40:37 -04:00
HARD_ADDITION,
HARD_SUBTRACTION,
2020-03-10 15:52:49 -04:00
HARD_MULTIPLICATION,
HARD_DIVISION,
2019-03-31 18:40:37 -04:00
};
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, const INPUT_STYLE &input_style);
2019-04-01 18:47:16 -04:00
void Input(const INPUT_STYLE input_style, char character);
void ClearInput() { input = ""; }
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;
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