图书管理系统(未完待续)

#include<bits/stdc++.h>
#include<map>
#include<vector>
using namespace std;
class Time
{
	int year, month,day;
	public:
	Time(int y,int m,int d)
	{
		year=y;month = m,day = d;

	}
	Time()
	{
	    year=2018;
		month = 1;
		day = 1;
	}
	friend bool operator<(Time t1,Time t2)
	{
if(t1.getMonth()==t2.getMonth())
{
    if(t1.getDay()<=t2.getDay())
    return 1;
}
else if(t1.getMonth()<=t2.getMonth())
{
    return 1;
}
return 0;
	}
	int getMonth(){return month;}
	int getDay(){return day;}
	int getYear(){return year;}
	void setMonth(int m){month=m;}
	void setDay(int d){day=d;}
	void setYear(int y){year=y;}
	void setTime(int y,int m,int d){year=y;month=m;day=d;}
	friend istream&operator>>(istream&is,Time&);
	friend ostream&operator<<(ostream&out,Time&);
};
 istream&operator>>(istream&is,Time&date)
 {
     is>>date.year>>date.month>>date.day;
          return is;
 }
ostream&operator<<(ostream&out,Time&date)
{
	out<<date.year<<" "<<date.month<<" "<<date.day<<endl;
	return out;
}
class Book
{
    string bookname;
    string author;
    int number;//书号
    int ceshu;
    public:
    Book(string bkname,string author,int num,int cs)
    {
        bookname=bkname;
        author=author;
        number=num;
        ceshu=cs;
    }
    Book()
    {
       bookname=" ";
       author=" ";
       number=000;
       ceshu=10;
    }

	string getBookname(){return bookname;}
	string getAuthor(){return author;}
	int getNumber(){return number;}
	int getCeshu(){return ceshu;}
	void setBookname(string bkname){bookname=bkname;}
	void setAuthor(string zuozhe){author=zuozhe;}
	void setBook(string bkname,string zuozhe,int num,int cs){bookname=bkname;author=zuozhe;ceshu=cs;}
	friend istream&operator>>(istream&is,Book&);
	friend ostream&operator<<(ostream&out,Book&);
};
istream&operator>>(istream&is,Book&B)
	{
	    is>>B.bookname;
	    if(B.bookname=="end")return is;
	    is>>B.author>>B.number>>B.ceshu;
	    return is;
	}
	ostream&operator<<(ostream&out,Book&B)
	{
		out<<B.bookname<<" "<<B.author<<" "<<B.number<<" "<<B.ceshu<<endl;
		return out;
	}
class Student//学生信息
{
	    string name;
	    int xuehao;
	    int hadborrow;
	    int canborrow;
	    public:
	    Student(int mingzi,int xh,int yijie,int kejie)
	    {
	      name=mingzi;
	      xuehao=xh;
	      hadborrow=yijie;
	      canborrow=kejie;
	    }
	    Student()
	    {
	        name="王睿君";
	        xuehao=20171760;
	        hadborrow=0;
	        canborrow=10;
	    }
	    string getName(){return name;}
	    int getXuehao(){return xuehao;}
	    int getHadborrow(){return hadborrow;}
	    int gatCanborrow(){return canborrow;}
	    void setName(string mingzi){name=mingzi;}
	    void setXuehao(int xh){xuehao=xh;}
	    void setStudent(string mingzi,int xh,int yijie,int kejie){name=mingzi;xuehao=xh;hadborrow=yijie;canborrow=kejie;}
        friend istream&operator>>(istream&is,Student&);
	    friend ostream&operator<<(ostream&out,Student&);
};
    istream&operator>>(istream&is,Student&S)
	{
	    is>>S.name>>S.xuehao>>S.hadborrow>>S.canborrow;
	    return is;
	}
	ostream&operator<<(ostream&out,Student&S)
	{
		out<<S.name<<" "<<S.xuehao<<" "<<S.hadborrow<<" "<<S.canborrow<<endl;
		return out;
	}
class Record
{
    Time borrow;
    Time back;
    Book b;
    Student s;
    string name1;
    public:
    Record(Time t1,Time t2,Book b1,Student s1,string nm1  )
    {
        borrow=t1;
        back=t2;
        b=b1;
        s=s1;
        name1=nm1;
    }
    Record(){}
    Time getTime1(){return borrow;}
    Time getTime2(){return back;}
    Book getBook(){return b;}
    Student getStudent(){return s;}
    friend ostream&operator<<(ostream&os,Record&r);
    friend istream&operator>>(istream&is,Record&r);
};
istream&operator>>(istream&is,Record&r)
{
    is>>r.s;
    if(r.)
}

猜你喜欢

转载自blog.csdn.net/Andrelia20171760/article/details/80525829
今日推荐