1 Star 0 Fork 0

安装怪/lms

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Actions.cpp 1.95 KB
一键复制 编辑 原始数据 按行查看 历史
安装怪 提交于 2018-02-09 22:32 . 增加学生相关信息
//
#include "stdafx.h"
#include "Actions.h"
#include <iostream>
#include <sstream>
using namespace std;
/**
* Allows registering a new student by entering all necessary information.
*/
int Actions::CreateStudent(LMS *sys, IO *io) {
string studentId = io->readStudentID();
string name = io->read("姓名");
int maths = io->readInt("数学成绩", 0, 100);
int computer = io->readInt("计算机成绩", 0, 100);
int english = io->readInt("英语成绩", 0, 100);
sys->AddStudent(studentId, name, maths, computer, english);
cout << "学生注册成功" << endl;
return 0;
};
/**
* Allows querying for a single student and delete it.
*/
int Actions::RemoveStudent(LMS *sys, IO *io) {
string studentId = io->readStudentID();
Student* student = new Student();
student->SetStudentId(studentId);
sys->DeleteStudent(student);
delete student;
cout << "成功删除学生." << endl;
return 0;
};
/**
* Shows detailed information about one or more students.
*/
int Actions::StudentsInfo(LMS *sys, IO *io) {
Student * student = io->readStudents(sys);
sys->FilterStudent(student);
return 0;
};
/**
* ALlows querying for a single student and update its properties.
*/
int Actions::UpdateStudent(LMS *sys, IO *io) {
cout << "请输入新数据:" << endl;
CreateStudent(sys, io);
return 0;
};
/**
* Allows exporting all student records to the specified file path.
*/
int Actions::ExportStudents(LMS *sys, IO *io) {
cout << "所有学生信息都会存档到本地目录." << endl;
cout << "如果本地有同名文件,存档会覆盖该文件" << endl;
cout << "文件路径可以设置为绝对路径或相对路径." << endl;
string filePath = io->read("文件名称");
filePath += ".txt";
sys->Save(( char *)filePath.c_str());
cout << "Export done." << endl;
return 0;
};
int Actions::ShowAllStudents(LMS *sys, IO *io) {
sys->Print();
return 0;
}
int Actions::RemoveAll(LMS *sys, IO *io) {
sys->Clear();
return 0;
}
int Actions::Exit(LMS *sys, IO *io) {
system("exit");
return 0;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/anzhuangguai/lms.git
git@gitee.com:anzhuangguai/lms.git
anzhuangguai
lms
lms
master

搜索帮助