图书馆管理系统总结:
图书馆管理系统的主要功能为:图书的增加、删除、查询、借阅、学生的增加和删除以及更改记录。
主要的类有:时间类、图书类、学生类、管理员类和用户类。
时间类Time:借阅时间以及图书归还时间。
纪录类Record:借书和还书记录。
图书类Book:储存图书的信息。
学生类User:储存学生的信息。
管理员类Manage:实现图书基本信息的存入、读取以及借阅记录的调取,使用load和save实现图书基本信息的读取与存入。
用户类Client:实现用户基本信息的录入与读取,包括借书、还书、续借以及违纪情况,借阅时间、还书时间以及是否续借。
总结:
图书馆管理系统是一个较复杂的程序,在编写过程中出现了许多错误,用了很长时间才把错误全部改正把程序写完。程序功能的实现运用了类、运算符重载、STL等知识,其中对STL使用不熟练,过程中出现了很多错误。这次系统整体存在许多问题,功能的实现也存在很多缺陷,希望以后越写越熟练。
代码:
using namespace std;
class Time
{
int year,month,day;
public:
Time(int x,int y,int z):year(x),month(y),day(z){};
Time(){year=2018,month=1,day=1;}
int getyear(){
return year;}
int getmonth(){
return month;}
int getday(){
return day;}
void setyear(int year){
this->year=year;}
void setmonth(int month){
this->month=month;}
void setday(int day){
this->day=day;}
bool operator<(const Time &d2)const
{
return year!=d2.year?year<d2.year:month!=d2.month?month<d2.month:day<d2.day;
}
friend istream& operator>>(istream &is,Time &t);
friend ostream& operator<<(ostream &os,const Time &t);
friend Time operator+(Time m,int i);
void display();
};
Time operator+(Time m,int i)
{
m.month=m.month+i;
if(m.month+i>12)
{
m.month=m.month-12;
m.year++;
}
return m;
}
istream& operator>>(istream &is,Time &t)
{
is>>t.year;
is>>t.month;
is>>t.day;
return is;
}
ostream& operator<<(ostream &os,const Time &t)
{
os<<t.year<<" ";
os<<t.month<<" ";
os<<t.day<<" ";
return os;
}
void Time::display()
{
cout<<year<<" "<<month<<" "<<day<<endl;
}
class Record
{
int id;
Time begin;
Time end;
int sh;
int xj;
int state;
public:
Record(){};
Record(int i,Time s,int h)
{
id=i;
begin=s;
sh=h;
if(s.getmonth()+2>12)
{
Time x(s.getyear()+1,s.getmonth()-12,s.getday());
end=x;
}
else
{
Time x(s.getyear(),s.getmonth()+2,s.getday());
end=x;
}
xj=0;
state=0;
}
int getid(){
return id;}
int getsh(){
return sh;}
int getxj(){
return xj;}
int getstate(){
return state;}
Time getbegin(){
return begin;}
Time getend(){
return end;}
void setid(int id){
this->id=id;}
void setsh(int sh){
this->sh=sh;}
void setxj(){xj=1;}
void setstate(int state){
this->state=state;}
void setbegin(Time begin){
this->begin=begin;}
void setend();
friend istream &operator>>(istream &is,Record &t);
friend ostream &operator<<(ostream &os,const Record &t);
};
istream &operator>>(istream&is,Record &t)
{
if(t.id==-1)
return is;
is>>t.id;
is>>t.begin;
is>>t.end;
is>>t.sh;
is>>t.xj;
is>>t.state;
return is;
}
ostream &operator<<(ostream&os,const Record &t)
{
os<<t.id<<" ";
os<<t.begin<<" ";
os<<t.end<<" ";