设计题目 |
评教管理系统 |
已知技术参数和设计要求 |
1、 该系统主要处理日常评教信息。 2、 学生信息、教师信息、评教信息读写。 3、 评教信息的添加、修改、删除、查询。 4、 用类模板实现至少一个类,各种信息加入向量或链表,代码中至少有一处用到异常处理。 |
设计内容与步骤 |
1、 模块化程序设计。 2、 具体数据结构的定义及其处理数据算法的设计。 3、 锯齿型程序书写格式 4、 程序设计、实现、调试。 5、 课程设计说明书。 |
设计工作计划与进度安排 |
1、 程序设计10学时。 2、 实现与调试6学时。 3、 课程设计说明书4学时。 |
设计考核要求 |
1、 考勤20%。 2、 课程设计说明书30%。 3、 答辩、成果演示50%。 |
#include
#include
#include
using namespace std;
template<typename T>
class Person
{
public:
Person(){}
~Person(){}
T getnum() { return num;}
T getname() { return name;}
void setnum(T sn) { num = sn; }
void setname(T na) { name = na; }
private:
T num;
T name;
};
class Teacher
{
friend istream& operator>>(istream&, Teacher&);
friend ostream& operator<<(ostream&, const Teacher&);
public:
Teacher& operator=(const Teacher&);
Teacher() {}
int curriculumID;//课程号
char className[12];
int classnumber;
int semester;//学期
int teacherID;//教师号
char NAME[12];
char college[10];//大学
char Assess[1000];//评价
};
istream& operator>>(istream &is, Teacher &t)
{
cout << "please enter the curriculum's id:"; is >> t.curriculumID;
cout << "please enter the curriculum's name:"; is >> t.className;
cout << "please enter the curriculum's semester:"; is >> t.semester;
cout << "please enter the curriculum's college:"; is >> t.college;
cout << "please enter the curriculum's number:"; is >> t.classnumber;
cout << "please enter the curriculum's assess:"; is >> t.Assess;
cout << "please enter the teacher's ID:"; is >> t.teacherID;
cout << "please enter the teacher's name:"; is >> t.NAME;
return is;
}
ostream& operator<<(ostream &os, const Teacher &t)
{
os << "The information of this curriculun:" << endl;
os << endl;
os << "the curriculum's id:" << t.curriculumID << endl;
os << "the curriculum's name:" << t.className << endl;
os << "the curriculum's college:" << t.college << endl;
os << "the curriculum's number:" << t.classnumber << endl;
os << "the curriculum's semester:" << t.semester << endl;
os << "the curriculum's address:" << t.Assess << endl;
os << "the teacher's ID:" << t.teacherID << endl;
os << "the teacher's name:" << t.NAME << endl;
return os;
}
Teacher& Teacher::operator=(const Teacher &t2)
{
curriculumID = t2.curriculumID;
strcpy(className, t2.className);
strcpy(college, t2.college);
classnumber = t2.classnumber;
strcpy(Assess, t2.Assess);
semester = t2.semester;
teacherID = t2.teacherID;
strcpy(NAME, t2.NAME);
return *this;
}
void menu();
void menu_list();
void add(Teacher t[], int i);
void change(Teacher t[], int i, int id);
void del(Teacher t[], int i, int id);
void search(Teacher t[], int i, int id);
int main()
{
int x, i = 0,id;
Person<string>stu;
string num;
string name;
cout << "请输入学号:" << endl;
cin >> num;
cout << "请输入姓名:" << endl;
cin >> name;
stu.setnum(num);
stu.setname(name);
Teacher t[20];
menu();
do {
cout << "enter the function number you chose(enter 0,you will exit):" << endl;
cin >> x;
switch (x)
{
case 1: {
add(t, i);
i++;
menu_list();
break;
}
case 2: {
cout << "the changed curriculum's id:";
cin >> id;
change(t, i, id);
menu_list();
break;
}
case 3: {
cout << "the deleted curriculum's id:";
cin >> id;
del(t, i, id);
i--;
menu_list();
break;
}
case 4: {
cout << "the serched curriculum's id:";
cin >> id;
search(t, i, id);
menu_list();
break;
}
case 0:
break;
default: {
cout << "wrong import,enter again!" << endl;//错误的输入,请从新输入
}
}
} while (x != 0);
return 0;
}
void menu()
{
cout << "*****W*elcom to teaching assessment system******" << endl;
cout << endl;
cout << "Are you sure to enter the system?(Y/N)" << endl;
if((getchar()) == 'N' || (getchar()) == 'n')
{
cout << "You have logged down!" << endl;
exit(1);
}
else {
cout << "***********************************************" << endl;
cout << "| 1.Add the curriculum information |" << endl;
cout << "| 2.change the curriculum information |" << endl;
cout << "| 3.delete the curriculum information |" << endl;
cout << "| 4.search the curriculum information |" << endl;
cout << "***********************************************" << endl;
}
}
void menu_list()
{
cout << "***********************************************" << endl;
cout << "| 1.Add the curriculum information |" << endl;
cout << "| 2.change the curriculum information |" << endl;
cout << "| 3.delete the curriculum information |" << endl;
cout << "| 4.search the curriculum information |" << endl;
cout << "***********************************************" << endl;
}
void add(Teacher t[], int i)
{
cin >> t[i];
for (int k = 0; k < i; k++)
{
if (t[k].curriculumID == t[i].curriculumID)
{
cout << "this curriculum has existed!" << endl;
cout << "please input again!" << endl;
cin >> t[i];
break;
}
}
}
void change(Teacher t[], int i, int id)
{
int k = 0;
for (k = 0; k < i; k++)
{
if (t[k].curriculumID == id)
{
int ch;
cout << "------1.curriculum id------" << endl;
cout << "------2.class name---------" << endl;
cout << "------3.class number-------" << endl;
cout << "------4.semester-----------" << endl;
cout << "------5.teacher ID---------" << endl;
cout << "------6.teacher's name-----" << endl;
cout << "------7.college------------" << endl;
cout << "------8.assess-------------" << endl;
cout << "------9.all information----" << endl;
do
{
cout << "input the number you want to change(enter 0,you will exit):" << endl;
cin >> ch;
switch (ch)
{
case 1:
cout << "input changed curriculum id:" << endl;
cin >> t[k].curriculumID;
break;
case 2:
cout << "input changed class name:" << endl;
cin >> t[k].className;
break;
case 3:
cout << "input changed class number:" << endl;
cin >> t[k].classnumber;
break;
case 4:
cout << "input changed semester:" << endl;
cin >> t[k].semester;
case 5:
cout << "input changed teacher ID:" << endl;
cin >> t[k].teacherID;
break;
case 6:
cout << "input changeded teacher's name:" << endl;
cin >> t[k].NAME;
break;
case 7:
cout << "input changeded college:" << endl;
cin >> t[k].college;
break;
case 8:
cout << "input changeded assess:" << endl;
cin >> t[k].Assess;
break;
case 9:
cout << "input all information:" << endl;
cin >> t[k];
break;
case 0:
break;
default:
cout << "wrong import!" << endl;
cout << "enter again!" << endl;
break;
}
} while (ch != 0);
}
}
if (k == i)
{
cout << "the curriculum ID does not exist!" << endl;
cout << "enter the ID again!" << endl;
cin >> id;
for (int z = 0; z<i; z++) {
if (t[z].curriculumID == id)
{
int xh;
cout << "--------------------1.curriculum id-----------------" << endl;
cout << "--------------------2.class name--------------------" << endl;
cout << "--------------------3.class number------------------" << endl;
cout << "--------------------4.semester----------------------" << endl;
cout << "--------------------5.teacher ID--------------------" << endl;
cout << "--------------------6.teacher's name----------------" << endl;
cout << "--------------------7.college-----------------------" << endl;
cout << "--------------------8.assess------------------------" << endl;
cout << "--------------------9.all information---------------" << endl;
do
{
cout << "input the number you want to change(enter 0,you will exit!):" << endl;
cin >> xh;
switch (xh)
{
case 1:
cout << "input changed curriculum id:" << endl;
cin >> t[z].curriculumID;
break;
case 2:
cout << "input changede class name:" << endl;
cin >> t[z].className;
break;
case 3:
cout << "input changed class number:" << endl;
cin >> t[z].classnumber;
break;
case 4:
cout << "input changed semester:" << endl;
cin >> t[z].semester;
break;
case 5:
cout << "input changed teacher ID:" << endl;
cin >> t[z].teacherID;
break;
case 6:
cout << "input changed teacher's name:" << endl;
cin >> t[z].NAME;
break;
case 7:
cout << "input changed college:" << endl;
cin >> t[z].college;
break;
case 8:
cout << "input changed assess:" << endl;
cin >> t[z].Assess;
break;
case 9:
cout << "input all information:" << endl;
cin >> t[z];
break;
case 0:
break;
default:
cout << "wrong format! " << endl;
cout << "enter again!" << endl;
break;
}
} while (xh != 0);
}
}
}
}
void del(Teacher t[], int i, int id)
{
int c, k;
for (k = 0; k < i; k++)
{
if (t[k].curriculumID == id)
{
c = k;
cout << "the formation has been deleted!" << endl;
break;
}
}
if (k == i)
{
cout << "the curriculum ID does not exist!" << endl;
cout << "enter the ID again!" << endl;
cin >> id;
for (int z = 0; z < i; z++)
{
if (t[z].curriculumID == id) {
c = z;
cout << "the information has been deleted!" << endl;
break;
}
}
}
for (; c < i; c++)
t[c] = t[c + 1];
cout << "the curriculum information has been deleted!" << endl;
}
void search(Teacher t[], int i, int id)
{
int k = 0;
for (k = 0; k < i; k++)
{
if (t[k].curriculumID == id)
{
cout << t[k];
break;
}
}
if (k == i)
{
cout << "the curriculum you found does not exist!" << endl;
cout << "enter the curriculum id again!" << endl;
cin >> id;
for (int z = 0; z < i; z++)
{
if (t[z].curriculumID == id)
{
cout << t[z];
break;
}
}
}
}