#include #include #include"account.h" #include"case.h" #include"filemanage.h" #include"question_product.h" #include"tool.h" class ExamSystem{ private: Authenticator authenticator; Filemanage fileManage; QuestionProduction questionProduction; User* currentUser; bool IsUser = false; void SystemLogin(); void SystemProductQuestions(); void handleSwitchType(const std::string& newtype); void ProductQuestion(int num); public: void systemRun(); }; void ExamSystem::systemRun(){ std::cout<<"====欢迎使用中小学卷子自动生成系统===="< tokens = tool::split(Input); if(tokens.size() != 2){ std::cout<UserType<<"数学题目,请输入生成题目数量(输入-1将退出当前用户,重新登录):"; IsUser = true; } } void ExamSystem::SystemProductQuestions(){ std::string Input; getline(std::cin,Input); if(Input == "-1"){ currentUser = nullptr; IsUser = false; return ; } std::regex switchPattern("切换为(\\S+)"); std::smatch match; if(std::regex_match(Input,match,switchPattern)){ std::string newType = match[1].str(); handleSwitchType(newType); return ; } if(!tool::isNumber(Input)){ std::cout<<"请输入有效的数字(10~30)"<30){ std::cout<<"题目数量范围应为10~30"< Levels = {"小学","初中","高中"}; bool isLevel = false; for(std::string Level:Levels){ if(Level == newtype){ isLevel = true; } } if(!isLevel){ std::cout<<"请输入小学、初中和高中三个选项中的一个"<UserType = newtype; std::cout<<"准备生成"<UserType<<"数学题目,请输入生成题目数量:"; } void ExamSystem::ProductQuestion(int num){ std::cout<<"正在生成"<UserType<<"数学题目,请耐心等待ovo"< hadquestion = fileManage.getQuestions(currentUser->UserName); std::vector newquestions; int id = 1; while(id <= num){ Question tempQuestion = questionProduction.questionProduction(id,currentUser->UserType); int QuestionNum = hadquestion.size(); hadquestion.insert(tempQuestion.content); if(QuestionNum != hadquestion.size()){ newquestions.push_back(tempQuestion); id++; } } std::string filename = fileManage.saveQuestions(currentUser->UserName,newquestions); std::cout<<"试卷已成功生成并保存"<UserType<<"数学题目,保存至 "<