⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 3号文件.cpp

📁 一份功能详细的图书馆管理系统的软件(包含各种头文件和CPP文件,以及相关的文档).
💻 CPP
📖 第 1 页 / 共 2 页
字号:
class StuInfoManager:public stuinfovec{
protected:
	bool isModified;//学生信息是否已被修改还未保存
	int toRemvNodes;//做了删除标记的记录数
    char menuSelect();//菜单选择函数
	void dispTable();//显示表头findRecord()
	void dispRecord(Record*rec);//显示一条记录的信息
	int getIndex(float sum);//找出给定总分在所有记录中的名次
public:
	static char* subject_[];

public:
	StuInfoManager();
	virtual ~StuInfoManager();

	virtual void start(){   
		cout<<"        **************欢迎使用学生成绩管理系统*****************"<<endl;


};	                              
	virtual void handleMenu(){
		cout<<"A.显示记录"<<endl;
	    cout<<"B.查询记录"<<endl;
		cout<<"C.添加记录"<<endl;
		cout<<"D.删除记录"<<endl;
		cout<<"E.标记删除记录"<<endl;
		cout<<"F.修改记录"<<endl;
		cout<<"G.记录排序"<<endl;
		cout<<"H.保存记录"<<endl;
		cout<<"I.读取记录"<<endl;
		cout<<"J.结束程序"<<endl;
		cout<<"K.清空当前记录信息"<<endl;
		cout<<"L.找出给定总分在所有记录中的名次"<<endl;
};//菜单处理函数管理程序的用户界面操作
	virtual void displayRecords(){
	   int c=0;
       dispTable();
       for(Recordvec::iterator i=rec.begin();i!=rec.end();i++)
        {
          cout<<(*i)->number;
          cout<<"    "<<(*i)->name;
          cout<<"        "<<(*i)->gender;
          cout<<"     "<<(*i)->score[0]<<"    ";
          cout<<(*i)->score[1]<<"    ";
          cout<<(*i)->score[2]<<"    ";
          cout<<(*i)->score[3]<<"    ";     
          cout<<(*i)->score[4]<<"    ";
          cout<<(*i)->sum<<"    ";
          cout<<(*i)->average<<"      ";  
          cout<<(*i)->index<<endl;
          c++;
          if(c==20)
          {
             cout<<"请输入回车键继续显示."; 
             char ch;
             cin>>ch;
             while(ch!='\n')
             {cout<<"请输入回车键继续显示."; cin>>ch;}  //循环
       }  
    }  
};            //显示记录dsplayRecords()成员函数会通过取下标迭代遍历整个记录,显示所有的记录。每输出20个记录后会停下来,
	          //等待用户输入"回车"键后,再输出后面的记录。
	virtual void queryRecord(){char M;
		cout<<"请选择查询方式.A 学号. B 姓名. C 名次."<<endl;
		cin>>M;
		patten=M;
		if(M==A) {
            cout<<"请输入学号:";
            string s;    
            cin>>s;
            vector<Record*>::iterator i,j,k;
            i=recVec.begin();k=recVec.end();
            j=findRecord(i,s,0);/////////////调用StuInfoVec中的函数I为迭代器的对象。S为人的学号
			                    ////(Iterator from,string patten,int type)TYPE的作用?
                	            //virtual Iterator findRecord(Iterator from,string patten,int type)
                                //{
                                //   Iterator it;
                                /////   Iterator it_end = recVec.end();
                                //   for(it = from; it != it_end; it++)          //////////通过迭代来历遍VECTOR
                                //   {
	                                             ////      if((*it)->number==patten)return it;    ////////返回Record;
	                            //      if((*it)->name==patten)return it;
	                            //       if((*it)->index==type)return it;
	       
                                //   }
                                //   return it;              ///////怎么还要返回?
                                // }
			if(j!=k)            //到K-1;
            {
               dispTable();//显示一条记录的信息,抽象的概念 
               while(j!=k){dispRecord(j);j++;j=findRecord(j,s,0);}//////从第一个到最后一个连续查询
            }           ///显示信息。循环。 
            else cout<<"您所查询的信息不存在"<<endl; 
        }       
        if(M==B)
        {
            cout<<"请输入姓名:";
            string s;    //////////方法同上
            cin>>s;
            vector<Record*>::iterator i,j,k;
            i=recVec.begin();k=recVec.end();
            j=findRecord(i,s,0); 
            if(j!=k)
            {
               dispTable();
               while(j!=k){dispRecord(j);j++;j=findRecord(j,s,0);}//找出给定总分在所有记录中的名次
            }
            else cout<<"您所查询的信息不存在"<<endl; 
        }           
        if(M==C)
        {
            cout<<"请输入名次:";
            int s;    
            cin>>s;
            Iterator i,j,k;
            i=recVec.begin();k=recVec.end();
            j=findRecord(i," ",s);
            if(j!=k)
            {
               dispTable();//显示一条记录的信息
               while(j!=k){dispRecord(j);j++;j=findRecord(j," ",s);}
            }
            else cout<<"您所查询的信息不存在"<<endl; 
        }                       
    } 
};//查询记录
    virtual void addRecord(Record*rec){     //调用StuInfoVec的addRecord()成员函数添加到信息记录的末尾
		cout<<"请输入学生信息."<<endl;
		cin>>rec.number;
		cin>>rec.name;
		cin>>rec.gender;
		for(int x=0;x<NUM_SUBJECT;x++)
	    cin>>rec.score[x];	
        rec.sum=rec.sum+rec.score[x];
		rec.average=rec.sum/NUM_SUBJECT;
		rec.index=getindex(rec.sum);
	    StuInfoVec::addRecord(rec);
}	//添加记录/////////调用了protected成员函数getIndex()
	virtual void removeRecord()
	{
        int a;
        cout<<"1.标记待删除的记录."<<endl;
        cout<<"2.取消删除标记."<<endl;
        cout<<"3.删除标记待删除的记录."<<endl;    
        cout<<"选择具体的操作:";    
        cin>>a;
        while((a!=1)&&(a!=2)&&(a!=3)&&(a!=4))//////////可以考虑用SWITCH语句
        {
           cout<<"选择具体的操作:";    
           cin>>a; 
        }    
        if(a==1)removeNote(false);////BOOL类型
        if(a==2)removeNote(true); 
        if(a==3)
        {
            vector<Record*>::iterator i,j,k;
            i=recVec.begin();k=recVec.end();
            j=findRecord(i);////////findRecord(i,PATTEN,TUPE)
            if(j!=k)
            {
               dispTable();
               while(j!=k){dispRecord(j);j++;j=findRecord(j);}
               cout<<"是否确定删除全部标记删除的记录.(yes/no)";
               string s;
               cin>>s;
               while((s!="yes")&&(s!="no"))
               {
                   cout<<"是否确定删除全部标记删除的记录.(yes/no)";
                   cin>>s;
               }           
               if(s=="yes")cout<<"删除了"<<StuInfoVec::removePerform()<<"条待删除的记录."<<endl; 
            }/////////////////////返回的是C,即等待删除的记录的条数。
            else cout<<"没有标记删除的记录."<<endl;     
      }    
}     //删除记录//removeRecord()成员函数将启动一个子菜单,让用户选择具体的删除操作,
	                                     //包括标记待删除的记录,执行标记,取消指定记录的删除标记和取消全部标记。
	                                     //然后依据用户的选择调用removeNote()和removePerform()成员函数。
   virtual void removeNote(bool isToRemove)
	{
       
       if(isToRemove==false)
       {
           int a;
           cout<<"请选择条件(1.学号、2.姓名、3.名次):";
           cin>>a;
           while((a!=1)&&(a!=2)&&(a!=3))
           {
              cout<<"请选择条件(1.学号、2.姓名、3.名次):";
              cin>>a;
           }    
           if(a==1)
           {
            cout<<"请输入学号:";
            string s;    
            cin>>s;
            Iterator i,j,k;
            i=recVec.begin();k=recVec.end();
            j=findRecord(i,s,0);/////////////方法同上////////////////////////////////////////////////
            if(j!=k)
            {
               dispTable();
               dispRecord(j);
               cout<<"是否确定标记记录.(yes/no)";
               string s;
               cin>>s;
               while((s!="yes")&&(s!="no"))
               {
                   cout<<"是否确定标记记录.(yes/no)";
                   cin>>s;
               }           
               if(s=="yes")(*j)->toBeDeleted=true;   
            }  
            else cout<<"您所查询的信息不存在"<<endl;
           }       
           if(a==2)
           {
            cout<<"请输入姓名:";
            string s;    
            cin>>s;
            Iterator i,j,k;
            i=recVec.begin();k=recVec.end();
            j=findRecord(i,s,0);
            if(j!=k)
            {
               dispTable();
               dispRecord(j);
               cout<<"是否确定标记记录.(yes/no)";
               string s;
               cin>>s;
               while((s!="yes")&&(s!="no"))
               {
                   cout<<"是否确定标记记录.(yes/no)";
                   cin>>s;
               }           
               if(s=="yes")(*j)->toBeDeleted=true;   
            }  
            else cout<<"您所查询的信息不存在"<<endl;
           }             
           if(a==3)
           {
            cout<<"请输入名次:";
            int s;    
            cin>>s;
            Iterator i,j,k;
            i=recVec.begin();k=recVec.end();
            j=findRecord(i," ",s);
            if(j!=k)
            {
               dispTable();
               dispRecord(j);
               cout<<"是否确定标记记录.(yes/no)";
               string s;
               cin>>s;
               while((s!="yes")&&(s!="no"))
               {
                   cout<<"是否确定标记记录.(yes/no)";
                   cin>>s;
               }           
               if(s=="yes")(*j)->toBeDeleted=true;   
            }  
            else cout<<"您所查询的信息不存在"<<endl;
           }
       }                   
       if(isToRemove==true)
       {
           int a;
           cout<<"1.取消指定记录的删除标记."<<endl;
           cout<<"2.取消全部标记."<<endl;    
           cout<<"选择具体的操作:";    
           cin>>a;
           while((a!=1)&&(a!=2))
           {
             cout<<"选择具体的操作:";    
             cin>>a; 
           }    
         if(a==1)
         { 
           int a;
           cout<<"请选择条件(1.学号、2.姓名、3.名次):";
           cin>>a;
           while((a!=1)&&(a!=2)&&(a!=3))
           {
              cout<<"请选择条件(1.学号、2.姓名、3.名次):";
              cin>>a;
           }    
           if(a==1)
           {
            cout<<"请输入学号:";
            string s;    
            cin>>s;
            vector<Record*>::iterator i,j,k;
            i=recVec.begin();k=recVec.end();
            j=findRecord(i,s,0);
            if(j!=k)
            {
               dispTable();
               dispRecord(j);
               cout<<"是否确定取消记录的删除标记.(yes/no)";
               string s;
               cin>>s;
               while((s!="yes")&&(s!="no"))
               {
                   cout<<"是否确定取消记录的删除标记.(yes/no)";
                   cin>>s;
               }           
               if(s=="yes")(*j)->toBeDeleted=false;   
            }  
            else cout<<"您所查询的信息不存在"<<endl;
           }       
           if(a==2)
           {
            cout<<"请输入姓名:";
            string s;    
            cin>>s;
            vector<Record*>::iterator i,j,k;
            i=recVec.begin();k=recVec.end();
            j=findRecord(i,s,0);
            if(j!=k)
            {
               dispTable();
               dispRecord(j);
               cout<<"是否确定取消记录的删除标记.(yes/no)";
               string s;
               cin>>s;
               while((s!="yes")&&(s!="no"))
               {
                   cout<<"是否确定取消标记记录.(yes/no)";
                   cin>>s;
               }           
               if(s=="yes")(*j)->toBeDeleted=false;   
            }  
            else cout<<"您所查询的信息不存在"<<endl;
           }             
           if(a==3)
           {
            cout<<"请输入名次:";
            int s;    
            cin>>s;
            vector<Record*>::iterator i,j,k;
            i=recVec.begin();k=recVec.end();
            j=findRecord(i," ",s);
            if(j!=k)
            {
               dispTable();
               dispRecord(j);
               cout<<"是否确定取消标记录的删除标记.(yes/no)";
               string s;
               cin>>s;
               while((s!="yes")&&(s!="no"))
               {
                   cout<<"是否确定取消标记记录.(yes/no)";
                   cin>>s;
               }           
               if(s=="yes")(*j)->toBeDeleted=false;   
            }  
            else cout<<"您所查询的信息不存在"<<endl;
           }
         }                 
         if(a==2)  
         {
            vector<Record*>::iterator i,j,k;
            i=recVec.begin();k=recVec.end();
            j=findRecord(i);
            if(j!=k)
            {
               dispTable();
               while(j!=k){dispRecord(j);j++;j=findRecord(j);}
               cout<<"是否确定取消全部标记记录.(yes/no)";
               string s;
               cin>>s;
               while((s!="yes")&&(s!="no"))
               {
                   cout<<"是否确定取消全部标记记录.(yes/no)";
                   cin>>s;
               }           
               if(s=="yes")
               {
                   j=findRecord(i);
                   while(j!=k)
                   {(*j)->toBeDeleted=false;j++;j=findRecord(j);} 
               }    
            }
            else cout<<"没有标记删除的记录."<<endl;    
         }    
      }        
   }         
//标记删除记录

	virtual void modifyRecord()
	{
        int a;
        cout<<"请选择条件(1.学号、2.姓名、3.名次):";
        cin>>a;
        while((a!=1)&&(a!=2)&&(a!=3))
        {
           cout<<"请选择条件(1.学号、2.姓名、3.名次):";
           cin>>a;
        }    
        if(a==1)
        {
            cout<<"请输入学号:";
            string s;    
            cin>>s;
            vector<Record*>::iterator i,j,k;
            i=recVec.begin();k=recVec.end();
            j=findRecord(i,s,0);
            if(j!=k)
            {
               dispTable();
               dispRecord(j);
               cout<<"是否确定修改记录.(yes/no)";
               string s;
               cin>>s;
               while((s!="yes")&&(s!="no"))
               {
                   cout<<"是否确定修改记录.(yes/no)";
                   cin>>s;
               }           
               if(s=="yes")
               {
                   cout<<"请输入学生的信息:"<<endl;
                   cout<<"学号:";cin>>(*j)->number;    
                   cout<<"姓名:";cin>>(*j)->name;
                   cout<<"性别:";cin>>(*j)->gender;     
                   cout<<subject_[0]<<"成绩:";cin>>(*j)->score[0];
                   cout<<subject_[1]<<"成绩:";cin>>(*j)->score[1];
                   cout<<subject_[2]<<"成绩:";cin>>(*j)->score[2];
                   cout<<subject_[3]<<"成绩:";cin>>(*j)->score[3];
                   cout<<subject_[4]<<"成绩:";cin>>(*j)->score[4];
                   (*j)->sum=0;
                   for(int i=0;i<=4;i++)
                   (*j)->sum+=(*j)->score[i];
                   (*j)->average=(*j)->sum/5;
                   getIndex();
               }        

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -