[C++]图书馆 图书管理系统 源代码

程序:

#include<bits/stdc++.h>
using namespace std;
class Date
{
    private:
        int year;
        int month;
        int day;
    public:
        Date(int x,int y,int z):year(x),month(y),day(z){}
        Date(){}
        int getYear(){return year;}
        int getMonth(){return month;}
        int getDay(){return day;}
        void setYear(int x){year=x;}
        void setMonth(int x){month=x;}
        void setDay(int x){day=x;}
        friend ostream & operator <<(ostream & output,Date & obj)
        {
            output<<obj.year<<" "<<obj.month<<" "<<obj.day;
            return output;
        }
        friend istream & operator >>(istream & input,Date & obj)
        {
            input>>obj.year>>obj.month>>obj.day;
            return input;
        }
        bool operator <(const Date & obj)const
        {
            return obj.year!=year?year<obj.year:obj.month!=month?month<obj.month:day<obj.day;
        }
};
class Record
{
    private:
        string bookName;
        int bookIndex;
        string stuName;
        string type;//操作类型
        int stuID;
        Date opTime;
        Date endTime;
        bool ifback;//是否归还
    public:
        Record(){ifback=0;}
        Record(string book,int b,string s1,int s2,string ty,Date o,Date end,bool f)
        {
            bookName=book;
            bookIndex=b;
            stuName=s1;
            stuID=s2;
            type=ty;
            opTime=o;
            endTime=end;
            ifback=f;
        }
        string getName(){return bookName;}
        int getIndex(){return bookIndex;}
        string getstuName(){return stuName;}
        int getID(){return stuID;}
        Date getopTime(){return opTime;}
        Date getendTime(){return endTime;}
        bool getifback(){return ifback;}
        string getType(){return type;}
        void setType(string x){type=x;}
        void setName(string x){bookName=x;}
        void setIndex(int x){bookIndex=x;}
        void setstuName(string x){stuName=x;}
        void setID(int x){stuID=x;}
        void setopTime(Date t){opTime=t;}
        void setendTime(Date x){endTime=x;}//修改还书时间
        void setifback(bool f){ifback=f;}

        friend ostream & operator <<(ostream & out,Record & obj);
        friend istream & operator >>(istream & in,Record & obj);


};
ostream & operator <<(ostream & out,Record & obj)
{
    out<<obj.bookIndex<<" ";
    out<<obj.bookName<<" ";
    out<<obj.stuName<<" ";
    out<<obj.stuID<<" ";
    out<<obj.type<<" ";
    out<<obj.opTime<<"   ";
    out<<obj.endTime<<"    ";
    out<<obj.ifback;
    return out;
}
istream & operator >>(istream & in,Record & obj)
{
    in>>obj.bookIndex>>obj.bookName>>obj.stuName>>obj.stuID>>obj.type>>
    obj.opTime>>obj.endTime>>obj.ifback;

    return in;
}
class Records
{
    protected:
        int RecordNum;
        vector <Record> v1;
        vector <Record> ::iterator vit1;
        multimap<bool,int>m2;
        multimap<bool,int>::iterator mit2;//是否归还bool

    public:
        Records(){RecordNum=0;}
        int getRecordNum(){return RecordNum;}
        vector <Record>  & getRecord(){return v1;}
        multimap<bool,int> & getM2(){return m2;}

        void setRecordNum(int x){RecordNum=x;}
        //无删除记录与增加记录Op,book类中和student类中这两个函数不同
        void disAllRecord();//所有记录
        void disNobackRecord();//显示未还书记录


};

void Records::disAllRecord()
{
    for(int i=0;i<v1.size();++i)cout<<v1[i]<<endl;
}
void Records::disNobackRecord()
{
    if(m2.find(0)!=m2.end())
        for(mit2=m2.lower_bound(0);mit2!=m2.upper_bound(0);++mit2)
            cout<<v1[mit2->second]<<endl;
    else cout<<"no records!"<<endl;
}
class Book:public Records
{
    private:
        string name;
        int index;
        int tot;//总数
        int shengyu;//剩余数量
        char ch;//辅助格式
        multimap<int,int>m1;
   
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值