【文件属性】:
文件名称:C++课程设计简易图书管理系统
文件大小:447KB
文件格式:DOC
更新时间:2015-04-26 15:03:04
C++课程设计
通过C++实习简单的设计出图书管理系统
class Student
{
private:
int snumber;
string sname;
string ssex;
int sage;
string sdapt;
string srutime;
string sbiyetime;
string sjieyuetime;
int sjiecount;
public:
Student(int number=0,string name="0",string sex="0",int age=0,string dapt="0",
string rutime="0",string biyetime="0",string jieyuetime="0",int jiecount=0);
virtual ~Student();
int Getsnumber();
void Setsnumber(int number);
string Getsname();
void Setsname(string name);
string Getssex();
void Setssex(string sex);
int Getsage();
void Setsage(int age);
string Getsdapt();
void Setsdapt(string dapt);
string Getsrutime();
void Setsrutime(string rutime);
string Getsbiyetime();
void Setsbiyetime(string biyetime);
string Getsjieyuetime();
void Setsjieyuetime(string jieyutime);
int Getsjiecount();
void Setsjiecount(int jiecount);
void Studentshow();
};
2)将文本文件信息存入Stulist容器
int snumber;
string sname;
string ssex;
int sage;
string sdapt;
string srutime;
string sbiyetime;
string sjieyuetime;
int sjiecount;
//定义Stulist容器和相应迭代器
list Stulist;
list::iterator s_iter=Stulist.begin();
list::iterator iter=Stulist.begin();
//定义文件输入流,读取文件
ifstream infile2;
infile2.open("Student.txt",ios::in);
//将文本文件信息存入Stulist容器中
infile2>>snumber>>sname>>ssex>>sage>>sdapt>>srutime>>sbiyetime>>sjieyuetime>>
sjiecount;
Student std(snumber,sname,ssex,sage,sdapt,srutime,sbiyetime,sjieyuetime,sjiecount);
Stulist.push_back(std);
while(infile2>>snumber>>sname>>ssex>>sage>>sdapt>>srutime>>sbiyetime>>sjieyuet ime>>sjiecount)
{
Student std(snumber,sname,ssex,sage,sdapt,srutime,sbiyetime,sjieyuetime,
sjiecount);
Stulist.push_back(std);
}
3)查询学生信息
cout<<"1、显示所有信息\t\t2、查询某个学生"<>xuan;
if(xuan==1)
{
cout<<"全部学生信息如下:"<Studentshow();
}
}
else if(xuan==2)
{
cout<<"请输入您要查询学生的编号(20100128**)->>";
int xuehao;
int judge=0;
cin>>xuehao;
for(s_iter=Stulist.begin(); s_iter!=Stulist.end(); s_iter++)
{
if(s_iter->Getsnumber()==xuehao)
{
cout<<"查询结果如下:"<Studentshow();
judge=1;
break;
}
}
if(judge == 0)
{
cout<<"你要查找的学生不存在!"<>";
int number;
int judge=0;
int ok=0;
cin>>number;
for(s_iter=Stulist.begin(); s_iter!=Stulist.end(); s_iter++)
{
if(s_iter->Getsnumber()==number)
{
iter=s_iter;
iter->Studentshow();
judge=1;
break;
}
else{;}
}
cout<<"是否删除:1、是2、否->>";
cin>>ok;
if(judge==1 && ok==1)
{
Stulist.erase(s_iter);
ofstream Delestu;
Delestu.open("Student.txt",ios::out);
for(s_iter=Stulist.begin(); s_iter!=Stulist.end(); s_iter++)
{
Delestu<Getsnumber()<<""<Getsname()<<""<
Getssex()<<""<Getsage()<<""<Getsdapt()<<""<
Getsrutime()<<""<Getsbiyetime()<<""<Getsjieyuetime()
<<""<Getsjiecount()<