56 lines
1.1 KiB
C++
56 lines
1.1 KiB
C++
#ifndef DVEREB_PROBLEM_H
|
|
#define DVEREB_PROBLEM_H
|
|
|
|
#include <string>
|
|
#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.
|
|
// 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,
|
|
};
|
|
|
|
class Problem
|
|
{
|
|
public:
|
|
Problem(PROBLEM_TYPE type, unsigned short max_digits, unsigned win_x, unsigned win_y);
|
|
~Problem();
|
|
|
|
void Draw(bool selected);
|
|
void Input(const INPUT_STYLE input_style, char character);
|
|
bool Correct() const;
|
|
|
|
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;
|
|
|
|
// Helper Functions:
|
|
void GenerateNumbers(PROBLEM_TYPE type, unsigned short max_digits);
|
|
void GenerateWindow(unsigned win_x, unsigned win_y);
|
|
};
|
|
|
|
#endif
|