Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // operations to use
- #define OPNUM 2
- char GiveOperation(int);
- class ProblemSet
- {
- private:
- int Size;
- public:
- ProblemSet(int n) : Size(n)
- {
- }
- };
- class Problem
- {
- private:
- int Term1;
- int Term2;
- char Operator;
- public:
- Problem(int x, int y) : Term1(x), Term2(y)
- {
- Operator = GiveOperation(OPNUM);
- }
- int AskTheProblem()
- {
- //Timer.start();
- int UserAnswer;
- printf("%d %c %d = ",Term1,Operator,Term2);
- scanf("%d",&UserAnswer);
- return UserAnswer;
- //Timer.end();
- }
- int Calculate()
- {
- switch (Operator)
- {
- case '+':
- default:
- return Term1 + Term2;
- case '-':
- return Term1 - Term2;
- case '*':
- return Term1 * Term2;
- case '/':
- return Term1 / Term2;
- }
- }
- };
- /*
- class Timer
- {
- private:
- float Time;
- public:
- Timer()
- {
- }
- };
- */
- char GiveOperation(int OpsToUse)
- {
- int OpGranter = rand() % OpsToUse;
- switch (OpGranter)
- {
- case 0:
- default:
- return '+';
- break;
- case 1:
- return '-';
- break;
- case 2:
- return '*';
- break;
- case 3:
- return '/';
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment