You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
542 B
19 lines
542 B
#include "question_generator.h"
|
|
|
|
#include <chrono>
|
|
#include <random>
|
|
|
|
QuestionGenerator::QuestionGenerator() {
|
|
rng_.seed(std::chrono::steady_clock::now().time_since_epoch().count());
|
|
}
|
|
|
|
int QuestionGenerator::GetRandomNumber(int min, int max) {
|
|
std::uniform_int_distribution<int> dist(min, max);
|
|
return dist(rng_);
|
|
}
|
|
|
|
char QuestionGenerator::GetRandomOperator(const std::vector<char>& operators) {
|
|
if (operators.empty()) return '+';
|
|
std::uniform_int_distribution<int> dist(0, operators.size() - 1);
|
|
return operators[dist(rng_)];
|
|
} |