学生信息管理系统(含类与对象,继承与多态)

亲爱的帅哥美女还在为C++课设而烦恼吗?不要怕!让小新来拯救你!

小新的课设不仅功能齐全,而且足够炫酷(自认为,莫喷)包含了面向对象(C++)的类与对象,继承与多态。希望能够帮到你。

#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<fstream>
#include <conio.h>//使用getch()函数 
#include <string>
using namespace std;
#define len sizeof(struct Student)
#define SIZE 100//最大用户容量
int scount = 0;//用作储存当前已注册用户数

//抽象职工
class Worker
{
public:
		int ID;//部门编号,1为家长,2为学生 
		string Name;//职位姓名
	
		 //显示信息 
		 virtual void showInfo()=0;
		 //显示职位姓名 
		 virtual string getname()=0;
}; 
//老师
class Teacher:public Worker
{
	public:
		Teacher(int id,string name);
		virtual void showInfo();
	    virtual string getname(); 
	    void teacher_meun(void);
	    void teacher_Item();
}; 
//家长
class Parents:public Worker
{
	public:
	Parents(int id,string name);
	virtual void showInfo();
	virtual string getname(); 
	void parents_meun();
	void parents_Item();
};
//学生用户类
class User:public Worker
{
private:
	string phone;//电话
	string password;//密码
public:
	User(){	};//无参 
	//User(int id,string name);//有参 
	
	void Registers();//注册
	void Login();//登录
	void save();//保存
	void read();//读取
	
	virtual void showInfo();
	virtual string getname();
	void user_meun();
	void user_Item(); 
}us;

User user[SIZE];
struct Student {
	char num[10];  //学号
	char name[10]; //姓名
	char sex[10];  //性别
	int age;       //年龄
	char major[14];//专业
	char className[14];//班级
	char map[20];//家庭地址 
	char Englishscore[14];//英语成绩 
};
 
typedef struct Node//结点
{
	struct Student st;//数据域
 	struct Node *pNext;//指针域
}NODE, *PNODE;

Teacher::Teacher(int id,string name)
{
	ID=id;
	Name=name;
}
void Teacher::showInfo()
{
	cout<<"部门编号:"<<ID
	    <<"\t职位姓名:"<<Name
	    <<"\t管理学生信息"<<endl;
	    
}
string Teacher::getname()
{
	return string("老师");
}
Parents::Parents(int id,string name)
{
	ID=id;
	Name=name;
}
void Parents::showInfo()
{
	cout<<"部门编号:"<<ID
	    <<"\t职位姓名:"<<Name
	    <<"\t查找学生信息"<<endl;
	    
}
string Parents::getname()
{
	return string("家长");
}
void User::showInfo()
{
	cout<<"部门编号:"<<"3"
	    <<"\t职位姓名:"<<"学生"
	    <<"\t填写完善个人信息"<<endl;
}
string User::getname()
{
	return string("学生");
}

//保存(保存电话和密码) 
void User::save()
{
	ofstream ofile;
	ofile.open("user.txt", ios::out);

	for (int i = 0; i < scount; i++)
	{
		ofile << user[i].phone << endl;
		ofile << user[i].password << endl;
	}
	ofile.close();
}

//读取
void User::read()
{
	ifstream ifile;
	ifile.open("user.txt", ios::in);

	scount = 0;

	if (!ifile.is_open())
	{
		cout << "文件打开失败!" << endl;
		return;
	}

	for (int i = 0; !ifile.eof(); i++)
	{
		ifile >> user[i].phone;
		ifile >> user[i].password;
		scount++;
	}
	scount--;
	ifile.close();
}

//注册
void User::Registers()
{
	us.read();//读取已储存用户数据
	string ph;//电话
	string pw1;//新密码1
	string pw2;//新密码2
	for (int i = scount; i < SIZE; i++)//for之内一直进行 
	{
	here:
		cout << "\t\t\t【系统提示】请输入手机号:";
		cin >>ph;
		//判断新输入的用户信息是否已存在(如果已存在则重新输入)
		
		for (int i = 0; i < scount; i++)
		{
			if (ph == user[i].phone)
			{
				cout << "\t\t\t【系统提示】用户已存在!" << endl;
				goto here;//回头再开始 
			}
		}
		
		user[i].phone = ph;

		int chose; 
		cout << endl;
		cout << "\t\t\t┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n";
		cout << "\t\t\t┃       1.显示密码     2.隐藏密码      ┃\t\n";
		cout << "\t\t\t┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n";
		cout << "\t\t\t【系统提示】请输入你的选择:";
		cin >> chose;
		if (chose!=2&&chose!=1)
		{
			cout << "\t\t\t【系统提示】输入格式错误,请重新输入:";
			cin >> chose;
		}

		string pword;
		char ch, passwords0[20];
		int x = 0;
		
		string pword1;
		char ch1, passwords1[20];
		int x1 = 0;
		
		switch (chose)
		{
		case 1:
			cout << "\t\t\t【系统提示】请输入密码:";
			cin >> pword;
			user[i].password = pword;
			cout << "\t\t\t【系统提示】请再次密码:";
			cin >> pword1;
			if (pword1 != user[i].password)
			{
				cout << "\t\t\t【系统提示】密码不一致!" << endl;
				goto here;
			}
			else
			{
				scount++;//已注册用户加1
				cout << "\t\t\t【系统提示】注册成功!" << endl;
				us.save();//保存用户数据
			}
			break;
		case 2:
			cout << "\t\t\t【系统提示】请输入密码:";
			while ((ch = _getch()) != '\r' && x <= 20)
			{
				if (ch == '\b')
				{
					if (x > 0)
					{
						x--;
						cout << "\b \b";//密码支持退格的实现
					}
					else
						putchar(7);
				}
				else
				{
					passwords0[x++] = ch;
					printf("*");
				}
			}
			passwords0[x] = '\0';//标记 
			cout << endl;
			user[i].password = passwords0;

			cout << "\t\t\t【系统提示】请再次密码:";
			while ((ch1 = _getch()) != '\r' && x1 <= 20)
			{
				if (ch1 == '\b')
				{
					if (x1 > 0)
					{
						x1--;
						cout << "\b \b";//密码支持退格的实现
					}
					else
						putchar(7);
				}
				else
				{
					passwords1[x1++] = ch1;
					printf("*");
				}
			}
			passwords1[x1] = '\0';
			cout << endl;
			
			//比较两次输入的密码是否统一(如果不统一则重新输入)
			if (passwords1 != user[i].password)
			{
				cout << "\t\t\t【系统提示】密码不一致!" << endl;
				goto here;
			}
			else
			{
				scount++;//已注册用户加1
				cout << "\t\t\t【系统提示】注册成功!" << endl;
				us.save();//保存用户数据
			}
			break;
		}
		char choice;
		cout << "\t\t\t【系统提示】是否继续注册(Y/N)? :";
		while (1)
		{
			cin >> choice;
			if (choice == 'y' || choice == 'Y' || choice == 'n' || choice == 'N')
				break;
			else
				cout << "\t\t\t【系统提示】输入格式错误,请重新输入: ";
		}
		if (choice == 'n' || choice == 'N')
		{
			break;
		}
	}
}

//登录
void User::Login()
{
	us.read();//读取已储存用户数据
	string ph;//电话
	string pw;//密码
	int time = 0;//统计比较次数
cf:
	cout << "\t\t\t【系统提示】请输入手机号:";
	cin >> ph;
	int chose;
	cout << endl;
	cout << "\t\t\t┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n";
	cout << "\t\t\t┃       1.显示密码     2.隐藏密码      ┃\t\n";
	cout << "\t\t\t┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n";
	cout << "\t\t\t【系统提示】请输入你的选择:";
	cin >> chose;
	if (chose !=2&&chose!=1)
	{
		cout << "\t\t\t【系统提示】输入格式错误,请重新输入:";
		cin >> chose;
	}

	string pword;
	char ch, passwords0[20];
	int x = 0;
	switch (chose)
	{
	case 1:
		cout << "\t\t\t【系统提示】请输入密码:";
		cin >> pword;
		for (int i = 0; i < scount; i++)
		{
			if (ph == user[i].phone && pword == user[i].password)
			{
				time++;
				//cout << "\t\t\t【系统提示】登录成功!" << endl;
			}
		}
		if (time == 0)
		{
			cout << "\t\t\t【系统提示】手机号或密码错误!" << endl;
			goto cf;
		}
		break;
	case 2:
		cout << "\t\t\t【系统提示】请输入密码:";
		while ((ch = _getch()) != '\r' && x <= 20)
		{
			if (ch == '\b')
			{
				if (x > 0)
				{
					x--;
					cout << "\b \b";//密码支持退格的实现
				}
				else
					putchar(7);
			}
			else
			{
				passwords0[x++] = ch;
				printf("*");
			}
		}
		passwords0[x] = '\0';
		cout << endl;
		//依次比较已储存信息,比较是否匹配(如不匹配则提示错误)
		for (int i = 0; i < scount; i++)
		{
			if (ph == user[i].phone && passwords0 == user[i].password)
			{
				time++;
				cout << "\t\t\t【系统提示】登录成功!" << endl;
			}
		}
		if (time == 0)
		{
			cout << "\t\t\t【系统提示】手机号或密码错误!" << endl;
			goto cf;//重新输入 
		}
		break;
	}
}

//void OutputStudent();
//录入,保存到记事本 
PNODE InputStudent(void)
{
	int n;//学生的人数
 	NODE stu;//学生结构
 	//定义一个头结点并且为头结点分配内存(有头节点)
	PNODE pHead = (PNODE)malloc(sizeof(NODE));
 	//判断内存是否为空
	if(NULL == pHead)
	{
		cout<<"内存分配失败,程序终止!"<<endl;
 		exit(-1);
	}
 	//定义一个指向头结点的指针
	PNODE pTail = pHead;
	pTail->pNext = NULL;//清空指针域
	cout<<"请输入学生人数"<<endl;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		system("cls");//清屏
		cout<<"请输入第"<<i+1<<"个学生的学号"<<endl; 
		cin>>stu.st.num;
 		cout<<"请输入第"<<i+1<<"个学生的姓名"<<endl; 
		cin>>stu.st.name;
		cout<<"请输入第"<<i+1<<"个学生的性别"<<endl;
		
		{
			//char sex1[20];
			cout << "Please enter sex ('男' or '女'):" << endl;

			while (1)
			{
				cin >> stu.st.sex;
				if (strcmp(stu.st.sex, "男") == 0 || strcmp(stu.st.sex, "女") == 0)
				{
					cout << "Input right." << endl;
					break;
				}else 
				
				cout << "Input error." << endl;
			}
			cout << "------------------------------" << endl;

		} 
		//cin>>stu.st.sex;
		cout<<"请输入第"<<i+1<<"个学生的年龄"<<endl; 
		cin>>stu.st.age;
		cout<<"请输入第"<<i+1<<"个学生的专业"<<endl; 
		cin>>stu.st.major;
		cout<<"请输入第"<<i+1<<"个学生的班级"<<endl; 
		cin>>stu.st.className;
		cout<<"请输入第"<<i+1<<"个学生的家庭地址"<<endl; 
		cin>>stu.st.map;
		cout<<"请输入第"<<i+1<<"个学生的英语成绩"<<endl; 
		cin>>stu.st.Englishscore;
		PNODE pNew = (PNODE)malloc(sizeof(NODE));
		if(NULL == pNew)
		{
			cout<<"内存分配失败,程序终止!"<<endl;
 			exit(-1);
		}
		pNew->st=stu.st;
		pTail->pNext=pNew;
		pNew->pNext=NULL;
		pTail=pNew;
	cout<<"------学生录入成功-------"<<endl; 
	} 
	PNODE p=pHead->pNext;
	ofstream ofs("student.txt",ios::out);
	if(ofs==NULL)
	{
		cout<<"-------打开失败!-------"<<endl;
		exit(-1);
	}
//	ofs<<"序号\t姓名\t性别\t年龄\t专业\t班级\t家庭地址\t英语成绩"<<endl;
	while(p!=NULL)
	{
		ofs<<p->st.num<<"\t"<<p->st.name<<"\t"<<p->st.sex<<"\t"<<
		p->st.age<<"\t"<<p->st.major<<"\t"<<p->st.className<<"\t"<<p->st.map<<"\t"<<p->st.Englishscore<<endl;
		p = p->pNext;
	}
	ofs.close();
	cout<<"————保存成功—————"<<endl; 
	return pHead;
}
//输出学生信息
void OutputStudent(PNODE pHead)
{
	//定义一个指针用于遍历学生信息
	PNODE p = pHead->pNext;
	cout<<"-------------------------------学生信息---------------------------\n"; 
 	cout<<"序号\t姓名\t性别\t年龄\t专业\t班级\t家庭地址\t英语成绩\n";
	while(NULL != p)
	{
		cout<<p->st.num<<"\t"<<p->st.name<<"\t"<<p->st.sex<<"\t"<<p->st.age<<"\t"<<p->st.major<<"\t"<<p->st.className<<"\t"<<p->st.map<<"\t"<<p->st.Englishscore<<endl;
		p = p->pNext;
	}
}
//增加学生信息
void InsertStudent(PNODE pHead)
{
	PNODE p = pHead->pNext;
 	int i = 0;
    struct Student *p1, *p2;//指针变量
	p1=(struct Student*)malloc(len);
	int pos;//插入结点的位置
 	cout<<"请输入插入学生的位置:"<<endl;
	cin>>pos;
 	while(NULL != p && i<pos-1)
	{
		p=p->pNext;
 		i++;
	}
 	if(NULL == p || i>pos)
	{
		cout<<"插入结点的位置不存在!\n";
 		return;
	}
 	cout<<"你将在第"<<pos<<"个学生后面插入一个学生\n";
 	cout<<"请输入第"<<pos+1<<"个学生的序号:"<<endl;
	cin>>p1->num;
	cout<<"请输入第"<<pos+1<<"个学生的姓名:"<<endl;
	cin>>p1->name;
	cout<<"请输入第"<<pos+1<<"个学生的性别:"<<endl;
	
	{
		cout << "Please enter sex ('男' or '女'):" << endl;

			while (1)
			{
				cin >> p1->sex;
				if (strcmp(p1->sex, "男") == 0 || strcmp(p1->sex, "女") == 0)
				{
					cout << "Input right." << endl;
					break;
				}else 
				
				cout << "Input error." << endl;
			}
			cout << "------------------------------" << endl;

	}
	//cin>>p1->sex;
	cout<<"请输入第"<<pos+1<<"个学生的年龄:"<<endl;
	cin>>p1->age;
	cout<<"请输入第"<<pos+1<<"个学生的专业:"<<endl;
	cin>>p1->major;
	cout<<"请输入第"<<pos+1<<"个学生的班级:"<<endl;
	cin>>p1->className;
	cout<<"请输入第"<<pos+1<<"个学生的家庭住址:"<<endl;
	cin>>p1->map;
	cout<<"请输入第"<<pos+1<<"个学生的英语成绩:"<<endl;
	cin>>p1->Englishscore;
	PNODE pNew = (PNODE)malloc(sizeof(NODE));
 	if(NULL == pNew)
	{
		cout<<"动态内存分配失败,程序终止!"<<endl;
 		exit(-1);
	}
 	pNew->st = *p1;//pNew
	PNODE q = p->pNext;
	p->pNext = pNew;
	pNew->pNext = q;
	cout<<"-----录入学生成功------"<<endl; 
}

void DeleteStudent(PNODE pHead)
{
	PNODE p = pHead;
	int i = 0;
    int pos;//学生学号 
 	cout<<"请输入你需要删除的学生的序号:";
	cin>>pos;
 	while(NULL != p->pNext && i<pos-1)
	{
		p = p->pNext;
        i++;
	}
 	if(NULL == p->pNext||i>pos-1)
	{
		cout<<"没找到需要删除的学生的序号!\n";
 		return;
	}
 	PNODE q = p->pNext;
 	p->pNext=q->pNext;
 	free(q);
	q == NULL;
 	cout<<"你已经成功删除了第"<<pos<<"个学生的信息!\n";
}
	
//修改学生信息 
void ChangeStudent(PNODE pHead)
{
	char name[10];
	cout<<"-----请输入要修改学生的姓名-----"<<endl;
	PNODE p=pHead->pNext;//定义一个指针用于遍历学生信息
	
	scanf("%s",&name);
	while(p!=NULL) 
	{
		if(strcmp(name,p->st.name)==0)
		{
			cout<<"----------------------------学籍表----------------------------\n"; 
			cout<<"序号\t姓名\t性别\t年龄\t专业\t班级\t家庭地址\t英语成绩\n";
			cout<<"修改前的学生信息\n";
			cout<<p->st.num<<"\t"<<p->st.name<<"\t"<<p->st.sex<<"\t"<<p->st.age<<"\t"<<p->st.major<<"\t"<<p->st.className<<"\t"<<p->st.map<<"\t"<<p->st.Englishscore<<endl;
			system("pause"); 
			system("cls");//清屏
			cout<<"请输入新的学生序号:\n";
			cin>>p->st.num;
			cout<<"请输入新的学生姓名:\n";
			cin>>p->st.name; 
			cout<<"请输入新的学生性别:\n";
			
			{
				cout << "Please enter sex ('男' or '女'):" << endl;

				while (1)
				{
					cin >> p->st.sex;
					if (strcmp(p->st.sex, "男") == 0 || strcmp(p->st.sex, "女") == 0)
					{
						cout << "Input right." << endl;
						break;
					}else 
					
					cout << "Input error." << endl;
				}
				cout << "------------------------------" << endl;

			}
			//cin>>p->st.sex;
			cout<<"请输入新的学生年龄:\n";
			cin>>p->st.age;
			cout<<"请输入新的学生专业:\n";
			cin>>p->st.major;
			cout<<"请输入新的学生班级:\n";
			cin>>p->st.className;
			cout<<"请输入新的学生家庭地址:\n";
			cin>>p->st.map;
			cout<<"请输入新的学生英语成绩:\n";
			cin>>p->st.Englishscore;
			cout<<"修改成功请输入2将其查看"<<endl;     
		}
		p=p->pNext;
	}
	
}
//查找学生信息
void SearchStudent(PNODE pHead)
{
	char name[10];
	PNODE p=pHead->pNext;//定义一个指针用于遍历学生信息
	cout<<"请输入你要查找的学生姓名"<<endl;
	cin>>name;
	while(p!=NULL)
	{
		if(strcmp(name,p->st.name)==0)
		{
			cout<<"找到该学生!"<<endl;
			cout<<endl;
			cout<<"序号\t姓名\t性别\t年龄\t专业\t班级\t家庭地址\t英语成绩\n";
			cout<<p->st.num<<"\t"<<p->st.name<<"\t"<<p->st.sex<<"\t"<<p->st.age
			<<"\t"<<p->st.major<<"\t"<<p->st.className<<"\t"<<p->st.map<<"\t"<<p->st.Englishscore<<endl;
			break;
		}
		p=p->pNext;
	}
	if(p==NULL)
	{
		cout<<"没有找到该学生,请重新开始!"<<endl; 
	}
}

void ScortByEnglish(PNODE pHead)
{
	PNODE p, q;//定义两个指针
	p=(PNODE)malloc(sizeof(NODE));
	q=(PNODE)malloc(sizeof(NODE));
	NODE temp;//结构体类型 
 	for(p=pHead->pNext;NULL!=p;p=p->pNext)
	{
		for(q=p->pNext;NULL!=q;q=q->pNext)
		{
			if(p->st.Englishscore< q->st.Englishscore)//当前一个学生的语文成绩小于后一个学生的语文成绩时
			{
				temp.st  = p->st;//交换学生的位置
				p->st =  q->st;
				q->st = temp.st;
			}
		}
	}
	cout<<"排序成功!"<<endl;
}
void read(PNODE pHead)
{
 	pHead=(PNODE)malloc(sizeof(NODE)); 
	ifstream ifs("student.txt",ios::in);
	if(!ifs)
	{
		cout<<"文件打开失败!!!"<<endl; 
		exit (-1);
	}
	PNODE p=(PNODE)malloc(sizeof(NODE));
	pHead->pNext=p;
	cout<<"序号\t姓名\t性别\t年龄\t专业\t班级\t家庭地址\t英语成绩\n";
	while(ifs>>p->st.num>>p->st.name>>p->st.sex>>
	p->st.age>>p->st.major>>p->st.className>>p->st.map>>p->st.Englishscore)
	{
		cout<<p->st.num<<"\t"<<p->st.name<<"\t"<<p->st.sex<<"\t"<<p->st.age
		<<"\t"<<p->st.major<<"\t"<<p->st.className<<"\t"<<p->st.map<<"\t"<<p->st.Englishscore<<endl; 
		if(p==NULL)
		{
			break;
		}
	}
	ifs.close();
}

void countStudent(PNODE pHead)
{
	PNODE p=pHead->pNext;//从头开始 
	int count1=0,count2=0;
	char str1[20]="男",str2[20]="女";
	while(p!=NULL)
	{
		if(!strcmp(p->st.sex,str1))
		{
			count1=count1+1;
		}
		if(!strcmp(p->st.sex,str2))
		{
			count2=count2+1;
		}
		p=p->pNext;
	}
	cout<<"男生人数为:"<<count1<<" "<<"女生人数为:"<<count2<<"!"<<endl;
}
void Teacher::teacher_meun(void)
{

	cout<<"================================================================================\n\n";
	cout<<"------------------------ 请选择要操作的命令:-----------------------------------\n\n";
	cout<<"-------------------------- 1  输出学生信息--------------------------------------\n\n";
	cout<<"-------------------------- 2  增加学生信息--------------------------------------\n\n";
	cout<<"-------------------------- 3  删除学生信息--------------------------------------\n\n";
	cout<<"-------------------------- 4  修改学生信息--------------------------------------\n\n";
	cout<<"-------------------------- 5  查找学生信息--------------------------------------\n\n";
	cout<<"-------------------------- 6  通过英语成绩进行学生排序--------------------------\n\n";
	cout<<"-------------------------- 7  读取学生信息--------------------------------------\n\n";
	cout<<"---------------------------8 统计新生信息   ------------------------------------\n\n";
	cout<<"---------------------------9  退出系统    --------------------------------------\n\n";
	cout<<"================================================================================\n\n";
 	cout<<"请按任意将进入新生信息系统:\n";
	getchar();
}
void Teacher::teacher_Item()
{
		int Item;//保存操作命令
	 	PNODE pHead = NULL;//定义一个指针
		cout<<"请选择操作命令:";
		scanf("%d",&Item);
		switch(Item)
		{
			case 1://输出学生信息 
			{
				OutputStudent(pHead); 
			}
			break;
 	        case 2://增加学生信息 
			{
				InsertStudent(pHead);
			}  
          	break;
            case 3://删除学生信息 
			{
			   DeleteStudent(pHead);	
			}  
          break;
          case 4://修改学生信息
		  {
		  	ChangeStudent(pHead); 
		  } 
		  break;
		  case 5://查找学生信息
		  {
		      SearchStudent(pHead); 
		  }
		  break;
		case 6://对学生的英语成绩排序
			{
				ScortByEnglish(pHead);
				OutputStudent(pHead);
			}
			break;
		case 7:
		{
			read(pHead);
			//OutputStudent(pHead);
		}	
			break;
		case 8://统计
		
		{
			countStudent(pHead);
		}
		    break;		 
		case 9://退出
		{
			cout<<"------------------------******----------------------"<<endl;
			cout<<"-----------------*****---------*****----------------"<<endl;
			cout<<"--------------*****!感谢你的使用!*****------------"<<endl;
			cout<<"-----------------*****---------*****----------------"<<endl;
			cout<<"------------------------******----------------------"<<endl;
		 } 
		   break;
		default:
		    cout<<"您的输入有误,请检查后再输入!"<<endl;
			system("pause");
			system("cls"); 
	    } 
}
void User::user_meun()
{
	cout<<"================================================================================\n\n";
	cout<<"------------------------ 请选择要操作的命令:-----------------------------------\n\n";
	cout<<"-------------------------- 1  输入学生信息--------------------------------------\n\n";
	cout<<"-------------------------- 2  修改学生信息--------------------------------------\n\n";
	cout<<"---------------------------3  退出系统    --------------------------------------\n\n";
	cout<<"================================================================================\n\n";
 	cout<<"请按任意将进入新生信息系统:\n";
	getchar();
}
void User::user_Item()
{
		int Item;//保存操作命令
	 	PNODE pHead = NULL;//定义一个指针
		cout<<"请选择操作命令:";
		scanf("%d",&Item);
		switch(Item)
		{
		case 1://输入学生信息
			{
			   pHead=InputStudent();
			
			}
			break;
        case 2://修改学生信息
		  {
		  	ChangeStudent(pHead); 
		  } 
		  break;
		case 3://退出
		{
			cout<<"------------------------******----------------------"<<endl;
			cout<<"-----------------*****---------*****----------------"<<endl;
			cout<<"--------------*****!感谢你的使用!*****------------"<<endl;
			cout<<"-----------------*****---------*****----------------"<<endl;
			cout<<"------------------------******----------------------"<<endl;
		 } 
		   break;
		default:
		    cout<<"您的输入有误,请检查后再输入!"<<endl;
			system("pause");
			system("cls"); 
	    } 
}
void Parents::parents_meun()
{
	cout<<"================================================================================\n\n";
	cout<<"------------------------ 请选择要操作的命令:-----------------------------------\n\n";
	cout<<"-------------------------- 1  修改学生信息--------------------------------------\n\n";
	cout<<"-------------------------- 2  查找学生信息--------------------------------------\n\n";
	cout<<"---------------------------3  退出系统    --------------------------------------\n\n";
	cout<<"================================================================================\n\n";
 	cout<<"请按任意将进入新生信息系统:\n";
	getchar();
}
void Parents::parents_Item()
{
		int Item;//保存操作命令
	 	PNODE pHead = NULL;//定义一个指针
		cout<<"请选择操作命令:";
		scanf("%d",&Item);
		switch(Item)
		{
        case 1://修改学生信息
		  {
		  	ChangeStudent(pHead); 
		  } 
		  break;
		case 2://查找学生信息
		  {
		      SearchStudent(pHead); 
		  }
		  break;
		case 3://退出
		{
			cout<<"------------------------******----------------------"<<endl;
			cout<<"-----------------*****---------*****----------------"<<endl;
			cout<<"--------------*****!感谢你的使用!*****------------"<<endl;
			cout<<"-----------------*****---------*****----------------"<<endl;
			cout<<"------------------------******----------------------"<<endl;
		 } 
		   break;
		default:
		    cout<<"您的输入有误,请检查后再输入!"<<endl;
			system("pause");
			system("cls"); 
	    } 
}
int main()
{
	system("color 3f");
	User user;
	int chose =-1;
	cout<<endl;
	cout<<"\t\t\t┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n";
	cout<<"\t\t\t┃       1.注    册     2.登    录      ┃\t\n";
	cout<<"\t\t\t┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n";
	cout<<"\t\t\t【系统提示】请输入你的选择:";
	cin>>chose;
	if (chose>2||chose<-1)
	{
		cout<<"\t\t\t【系统提示】输入格式错误,请重新输入:";
		cin>>chose;
	}
	switch (chose)
	{
	case 1:
	   user.Registers(); 
	   break;
	case 2:
	   user.Login();
	   break;
	default:
		    cout<<"您的输入有误,请检查后再输入!"<<endl;
			system("pause");
			system("cls");    
	}
	system("mode con cols=150 lines=40");
	system("color 3f");
	cout<<"================================================================================\n\n";
	cout<<"================================================================================\n\n";
	cout<<"*************************欢迎使用新生信息系统*******************************\n\n";
	cout<<"********************************************************************************\n\n";
	cout<<"================================================================================\n\n";
	getchar();
	system("cls");
    cout<<"请按任意将进入新生信息系统:\n";
	getchar();
	system("cls");
	while(1)
	{
		Worker *p;
		Teacher person1(1,"老师");
		Parents person2(2,"家长");
		User person3;
		
		p=&person1;
		p->showInfo();
		p->getname();
		
		p=&person2;
		p->showInfo();
		p->getname();
		
		p=&person3;
		p->showInfo();
		p->getname();
		
		cout<<"请输入您的身份(选择对应序号):"
		    <<"\t 1:老师"
		    <<"\t 2:家长"
		    <<"\t 3:学生"<<endl;
		int choice;
		cin>>choice;
		switch(choice)
		{
			case 1:
				
				{
					cout<<"进入老师面板:"<<endl;
					person1.teacher_meun();
					cout<<"进入功能选择和执行请按0"<<endl;
					int a;
					cin>>a;
					switch(a)
					{
						case 0:
							person1.teacher_Item();
						//	break;
						default:
							cout<<"您的输入有误,请检查后再输入!"<<endl;
							system("pause");
							system("cls"); 
					}
					
				}
				break;
			case 2:
				
				{
					cout<<"进入家长面板:"<<endl;
					person2.parents_meun();
					cout<<"进入功能选择和执行请按0"<<endl;
					int a;
					cin>>a;
					switch(a)
					{
						case 0:
							person2.parents_Item();
						//	break;
						default:
							cout<<"您的输入有误,请检查后再输入!"<<endl;
							system("pause");
							system("cls"); 
					}
				}
				break;
			case 3:
				
				{
					cout<<"进入学生面板:"<<endl;
					person3.user_meun();
					cout<<"进入功能选择和执行请按0"<<endl;
					int a;
					cin>>a;
					switch(a)
					{
						case 0:
							person3.user_Item();
						//	break;
						default:
							cout<<"您的输入有误,请检查后再输入!"<<endl;
							system("pause");
							system("cls"); 
					}
				}
				break;
			default:
				cout<<"您的输入有误,请检查后再输入!"<<endl;
				system("pause");
				system("cls"); 
		}
	return 0;
	}
}

编者语

千行代码,编写不易,各位帅哥美女给个点赞收藏吧!

小新也是一个正在努力的小白,代码如有错误,请指出。

  • 7
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
实验题目1:班级学生学期成绩管理系统 (1)程序功能简介 灵活运用类的继承、对象成员等机制,设计一个能够实现班级学生学期成绩管理的程序。 (2)程序设计说明 ① 个人信息类CPerson的数据成员有姓名、性别、年龄、身份证号等数据成员,成员函数根据需要自行设计; ② 学生类CStudent从CPerson派生,并增加学号、CCourse对象成员数组(大小至少3个)等数据成员,并根据需要自行设计成员函数,包括能够求解所选修课程的总学分、显示某个学生基本信息和课程信息的成员函数; ③ 课程类CCourse包括课程名、学分、分数、任课老师等数据成员,成员函数根据需要自行设计; ④ 班级类CClass的数据成员有班级名称、班级人数、CStudent对象成员数组(大小由构造函数确定)等。本班级类CClass的对象成员数组需要在构造函数用new动态分配内存空间,在析构函数用delete释放。在CClass类设计包括能够求解最高成绩、最低成绩和平均成绩以及通过学号查找并输出某个学生全部信息(例如Seek())等功能在内的成员函数; ⑤ 构造三十个学生的数据,每个学生都有三门课程成绩,输出并显示这些数据; ⑥ 根据类的需要添加适当的其它成员,编写完整的程序并测试。 (3)程序调试运行 运行程序查看结果,并进行源代码调试和优化。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值