parent
dd5445e710
commit
94fb7f94fe
@ -0,0 +1,40 @@
|
||||
#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_;
|
||||
}
|
||||
Loading…
Reference in new issue