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.

40 lines
1.1 KiB

#include "session_manager.h"
SessionManager::SessionManager()
: current_user_(""),
current_difficulty_(""),
current_generator_(nullptr) {}
void SessionManager::SetUser(const std::string& username,
const std::string& difficulty) {
current_user_ = username;
SwitchDifficulty(difficulty);
}
bool SessionManager::SwitchDifficulty(const std::string& difficulty) {
if (difficulty == "primary") {
current_generator_ = &primary_generator_;
current_difficulty_ = "小学";
} else if (difficulty == "junior") {
current_generator_ = &junior_generator_;
current_difficulty_ = "初中";
} else if (difficulty == "senior") {
current_generator_ = &senior_generator_;
current_difficulty_ = "高中";
} else {
return false;
}
return true;
}
QuestionGenerator* SessionManager::GetCurrentGenerator() {
return current_generator_;
}
std::string SessionManager::GetCurrentDifficulty() const {
return current_difficulty_;
}
std::string SessionManager::GetCurrentUser() const {
return current_user_;
}