|
|
|
|
#include "MangerBook.h"
|
|
|
|
|
#include "Book.h"
|
|
|
|
|
#include <fstream>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
|
|
MangerBook::MangerBook()//<2F><><EFBFBD>캯<EFBFBD><ECBAAF>
|
|
|
|
|
{
|
|
|
|
|
this->Book_Array = new vector<Book*>;
|
|
|
|
|
this->Init_Book();//<2F><>ʼ<EFBFBD><CABC>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MangerBook::Init_Book()
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
ifstream fi;
|
|
|
|
|
fi.open("D:/c++һЩ<D2BB><D0A9><EFBFBD><EFBFBD>/library class<73><73>/library class<73><73>/ͼ<><CDBC><EFBFBD><EFBFBD>Ϣ.txt",ios::in);
|
|
|
|
|
if (!fi.is_open()) {
|
|
|
|
|
std::cerr << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>" << std::endl;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string _name;
|
|
|
|
|
int _year,_month,_day;
|
|
|
|
|
int _isleadbook;
|
|
|
|
|
int _times;
|
|
|
|
|
while(fi>>_name&&fi>>_year&&fi>>_month && fi>>_day&&fi>>_isleadbook&&fi>>_times)
|
|
|
|
|
{
|
|
|
|
|
Date _data(_year,_month,_day);
|
|
|
|
|
Book *_pstu = NULL;
|
|
|
|
|
if(_isleadbook==0)
|
|
|
|
|
_pstu = new Book(_name,_data,true,_times);
|
|
|
|
|
else
|
|
|
|
|
_pstu = new Book(_name,_data,false,_times);
|
|
|
|
|
this->Book_Array->push_back(_pstu);
|
|
|
|
|
}
|
|
|
|
|
fi.close();
|
|
|
|
|
*/
|
|
|
|
|
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>飬<EFBFBD><E9A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>룬<EFBFBD><EBA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>Ҳû<D2B2>н<EFBFBD><D0BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܵĴ<DCB5><C4B4><EFBFBD>
|
|
|
|
|
Book* _pstu1 = NULL;
|
|
|
|
|
Date _data1(2024, 3, 4);
|
|
|
|
|
_pstu1 = new Book("<EFBFBD><EFBFBD><EFBFBD>ݽṹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", _data1, false, 117);
|
|
|
|
|
this->Book_Array->push_back(_pstu1);
|
|
|
|
|
|
|
|
|
|
Book* _pstu2 = NULL;
|
|
|
|
|
Date _data2(2023, 10, 17);
|
|
|
|
|
_pstu2 = new Book("<EFBFBD><EFBFBD>¥<EFBFBD><EFBFBD>", _data2, true, 11);
|
|
|
|
|
this->Book_Array->push_back(_pstu2);
|
|
|
|
|
|
|
|
|
|
Book* _pstu3 = NULL;
|
|
|
|
|
Date _data3(2024, 5, 16);
|
|
|
|
|
_pstu3 = new Book("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", _data3, false, 98);
|
|
|
|
|
this->Book_Array->push_back(_pstu3);
|
|
|
|
|
|
|
|
|
|
Book* _pstu4 = NULL;
|
|
|
|
|
Date _data4(2023, 10, 4);
|
|
|
|
|
_pstu4 = new Book("<EFBFBD><EFBFBD>ɢ<EFBFBD><EFBFBD>ѧ", _data1, true, 11);
|
|
|
|
|
this->Book_Array->push_back(_pstu4);
|
|
|
|
|
|
|
|
|
|
Book* _pstu5 = NULL;
|
|
|
|
|
Date _data5(2023, 2, 16);
|
|
|
|
|
_pstu5 = new Book("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ", _data5, false, 110);
|
|
|
|
|
this->Book_Array->push_back(_pstu5);
|
|
|
|
|
|
|
|
|
|
Book* _pstu6 = NULL;
|
|
|
|
|
Date _data6(2023, 10, 1);
|
|
|
|
|
_pstu6 = new Book("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", _data6, false, 111);
|
|
|
|
|
this->Book_Array->push_back(_pstu6);
|
|
|
|
|
}
|
|
|
|
|
void MangerBook::ShowMenu()
|
|
|
|
|
{
|
|
|
|
|
cout << "-----------------------------------------------------------" << endl;
|
|
|
|
|
cout << "-------------------ijij<C4B3><C4B3>ѧͼ<D1A7><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ---------------------" << endl;
|
|
|
|
|
cout << "----------------------0<><30><EFBFBD>˳<EFBFBD>ϵͳ--------------------------" << endl;
|
|
|
|
|
cout << "---------------------1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>а<EFBFBD>-------------------------" << endl;
|
|
|
|
|
cout << "---------------------2<><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>---------------------------" << endl;
|
|
|
|
|
cout << "---------------------3<><33><EFBFBD>鿴ͼ<E9BFB4><CDBC>---------------------------" << endl;
|
|
|
|
|
cout << "---------------------4<><34>ɾ<EFBFBD><C9BE>ͼ<EFBFBD><CDBC>---------------------------" << endl;
|
|
|
|
|
cout << "---------------------5<><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>---------------------------" << endl;
|
|
|
|
|
cout << "---------------------6<><36><EFBFBD>黹ͼ<E9BBB9><CDBC>---------------------------" << endl;
|
|
|
|
|
cout << "---------------------7<><37><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>---------------------------" << endl;
|
|
|
|
|
cout << "-----------------------------------------------------------" << endl;
|
|
|
|
|
cout << endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MangerBook::Exit_Sys()//<2F>˳<EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
cout << "ллʹ<EFBFBD><EFBFBD>" << endl;
|
|
|
|
|
exit(-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool cmp(Book* book1, Book* book2)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><CBB3><EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD>С
|
|
|
|
|
{
|
|
|
|
|
return book1->getTimes() > book2->getTimes();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MangerBook::LoanRanking()//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD>ʹ<EFBFBD><CAB9>STL<54><4C><EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
sort(Book_Array->begin(), Book_Array->end(), cmp);
|
|
|
|
|
for (int i = 0; i < (int)Book_Array->size(); i++) {
|
|
|
|
|
this->Book_Array->at(i)->ShowInfo();
|
|
|
|
|
}
|
|
|
|
|
system("pause");
|
|
|
|
|
system("cls");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MangerBook::ShowBook()//<2F><>ʾ<EFBFBD>ڿ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < (int)Book_Array->size(); i++) {
|
|
|
|
|
this->Book_Array->at(i)->ShowInfo();
|
|
|
|
|
}
|
|
|
|
|
system("pause");
|
|
|
|
|
system("cls");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MangerBook::AddBook()//<2F><><EFBFBD><EFBFBD><EFBFBD>鼮
|
|
|
|
|
{
|
|
|
|
|
int i = 1;//<2F><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
char flag;
|
|
|
|
|
string _name;
|
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>" << i << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << endl;
|
|
|
|
|
cin >> _name;
|
|
|
|
|
Book* _pstu = NULL;
|
|
|
|
|
Date _data(0, 0, 0);
|
|
|
|
|
_pstu = new Book(_name, _data, false, 0);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>Ĭ<EFBFBD>Ͻ<EFBFBD><CFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>
|
|
|
|
|
this->Book_Array->push_back(_pstu);
|
|
|
|
|
i++;
|
|
|
|
|
cout << "<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>" << endl;
|
|
|
|
|
cout << "Y/y<><79><EFBFBD><EFBFBD>¼<EFBFBD>룬N/n<><6E><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>" << endl;
|
|
|
|
|
while (true) { //<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
cin >> flag;
|
|
|
|
|
if (flag == 'Y' || flag == 'y' || flag == 'N' || flag == 'n')
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룡" << endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (flag == 'Y' || flag == 'y') {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
cout << "<EFBFBD>ɹ<EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << i - 1 << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>" << endl;
|
|
|
|
|
system("pause");
|
|
|
|
|
system("cls");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MangerBook::SearchBook()
|
|
|
|
|
{
|
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD>鼮<EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << endl;
|
|
|
|
|
string searchname;
|
|
|
|
|
cin >> searchname;
|
|
|
|
|
int index;
|
|
|
|
|
index = IndexBook(searchname);//Ѱ<><D1B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
if (index != -1) {
|
|
|
|
|
this->Book_Array->at(index)->ShowInfo();
|
|
|
|
|
}
|
|
|
|
|
system("pause");
|
|
|
|
|
system("cls");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int MangerBook::IndexBook(string name)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
int ret = -1;
|
|
|
|
|
for (int i = 0; i < (int)Book_Array->size(); i++) {
|
|
|
|
|
if (this->Book_Array->at(i)->getName() == name) {
|
|
|
|
|
ret = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MangerBook::SelectBook()
|
|
|
|
|
{
|
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD>鼮<EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << endl;
|
|
|
|
|
string searchname;
|
|
|
|
|
cin >> searchname;
|
|
|
|
|
int index;
|
|
|
|
|
index = IndexBook(searchname);
|
|
|
|
|
if (index != -1) {
|
|
|
|
|
if (this->Book_Array->at(index)->getStatue() == false) {//<2F>鼮<EFBFBD><E9BCAE><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>
|
|
|
|
|
this->Book_Array->erase(this->Book_Array->begin() + index);
|
|
|
|
|
cout << "ɾ<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>" << endl;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
cout << "<EFBFBD>鼮<EFBFBD><EFBFBD><EFBFBD>ڿ⣡<EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>" << endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
cout << "<EFBFBD>鼮<EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>" << endl;
|
|
|
|
|
}
|
|
|
|
|
system("pause");
|
|
|
|
|
system("cls");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MangerBook::LoanBook()//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>鼮<EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << endl;
|
|
|
|
|
string searchname;
|
|
|
|
|
cin >> searchname;
|
|
|
|
|
int c_year, c_month, c_day;
|
|
|
|
|
int index;
|
|
|
|
|
index = IndexBook(searchname);
|
|
|
|
|
if (index != -1) {
|
|
|
|
|
if (this->Book_Array->at(index)->getStatue() == false) {//<2F>鼮<EFBFBD><E9BCAE><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD><EFBFBD><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD> <20><> <20>գ<EFBFBD>" << endl;
|
|
|
|
|
cin >> c_year >> c_month >> c_day;
|
|
|
|
|
Date c_data(c_year, c_month, c_day);
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>黹<EFBFBD><E9BBB9><EFBFBD><EFBFBD><EFBFBD>ڵĺϷ<C4BA><CFB7><EFBFBD>
|
|
|
|
|
if (!LegalDate(c_data)) {
|
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD>ڷǷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룡" << endl;
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>
|
|
|
|
|
while (true) {
|
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD> <20><> <20>գ<EFBFBD>" << endl;
|
|
|
|
|
cin >> c_year >> c_month >> c_day;
|
|
|
|
|
c_data = Date(c_year, c_month, c_day);
|
|
|
|
|
if (LegalDate(c_data)) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD>ڷǷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룡" << endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Book* _pstu1 = NULL;
|
|
|
|
|
Date _data1(c_year, c_month, c_day);
|
|
|
|
|
_pstu1 = new Book(searchname, _data1, true, this->Book_Array->at(index)->getTimes() + 1);
|
|
|
|
|
int insertIndex = index; // Ҫ<><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD>Ը<EFBFBD><D4B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<DEB8>
|
|
|
|
|
if (insertIndex >= 0 && insertIndex < (int)this->Book_Array->size()) {
|
|
|
|
|
delete this->Book_Array->at(insertIndex); // ɾ<><C9BE>ԭ<EFBFBD><D4AD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><F3A3ACB1><EFBFBD><EFBFBD>ڴ<EFBFBD>й©
|
|
|
|
|
this->Book_Array->at(insertIndex) = _pstu1; // <20><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> Book <20><><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD>" << endl;
|
|
|
|
|
}
|
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʊ<EFBFBD><EFBFBD><EFBFBD>" << endl;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
cout << "<EFBFBD>鼮<EFBFBD><EFBFBD><EFBFBD>ڿ⣡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>" << endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
cout << "<EFBFBD>鼮<EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>" << endl;
|
|
|
|
|
}
|
|
|
|
|
system("pause");
|
|
|
|
|
system("cls");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isLeapyear(int year)//<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MangerBook::LegalDate(const Date& date) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ںϷ<DABA><CFB7><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
int y = date.getYear();
|
|
|
|
|
int m = date.getMonth();
|
|
|
|
|
int d = date.getDay();
|
|
|
|
|
bool ret = true;
|
|
|
|
|
if (m > 12 || m < 1)
|
|
|
|
|
ret = false;
|
|
|
|
|
else if (((m == 1) || (m == 3) || (m == 5) || (m == 7) || (m == 8) || (m == 10) || (m == 12)) && d > 31)
|
|
|
|
|
ret = false;
|
|
|
|
|
else if (((m == 4) || (m == 6) || (m == 9) || (m == 11)) && d > 30)
|
|
|
|
|
ret = false;
|
|
|
|
|
if (isLeapyear(y) && m == 2 && d > 29)
|
|
|
|
|
ret = false;
|
|
|
|
|
else if (!isLeapyear(y) && m == 2 && d > 28)
|
|
|
|
|
ret = false;
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int diffDay(int year1, int year2, int month2, int day2)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD>죬<EFBFBD><ECA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
int ans = 0;
|
|
|
|
|
if (year1 == year2)
|
|
|
|
|
return 0;
|
|
|
|
|
else if (year1 > year2)
|
|
|
|
|
return -1e6;
|
|
|
|
|
int cntyear = abs(year2 - year1);
|
|
|
|
|
for (int i = 0; i < cntyear; i++) {
|
|
|
|
|
ans += 365;
|
|
|
|
|
}
|
|
|
|
|
for (int i = min(year1, year2); i <= max(year1, year2); i++) {
|
|
|
|
|
if (isLeapyear(i)) {
|
|
|
|
|
ans++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (isLeapyear(year2) && ((month2 < 2) || (month2 == 2 && day2 < 29)))
|
|
|
|
|
ans--;
|
|
|
|
|
return ans;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Daytoend(int y, int m, int d) //<2F><><EFBFBD>㵽<EFBFBD><E3B5BD><EFBFBD><EFBFBD><D7B5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
int tm = 0, tEY = 0;
|
|
|
|
|
int month[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
|
|
|
|
|
if (isLeapyear(y))
|
|
|
|
|
month[1] = 29;
|
|
|
|
|
for (m -= 1; m <= 11; m++)
|
|
|
|
|
tm += month[m];
|
|
|
|
|
tEY = tm - d;
|
|
|
|
|
return tEY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int MangerBook::CntDay(const Date& date1, const Date& date2)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
int cntday1 = diffDay(date1.getYear(), date2.getYear(), date2.getMonth(), date2.getDay());
|
|
|
|
|
int cnt_day_end1 = Daytoend(date1.getYear(), date1.getMonth(), date1.getDay());
|
|
|
|
|
int cnt_day_end2 = Daytoend(date2.getYear(), date2.getMonth(), date2.getDay());
|
|
|
|
|
int CalculateDateDifference = cntday1 + cnt_day_end1 - cnt_day_end2;
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD>Ϊ<EEBCB4><CEAA><EFBFBD><EFBFBD>
|
|
|
|
|
return CalculateDateDifference;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MangerBook::ReturnkBook()//<2F>黹<EFBFBD>鼮
|
|
|
|
|
{
|
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>黹<EFBFBD>鼮<EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << endl;
|
|
|
|
|
string searchname;
|
|
|
|
|
cin >> searchname;
|
|
|
|
|
int r_year;
|
|
|
|
|
int r_month;
|
|
|
|
|
int r_day;
|
|
|
|
|
int index;
|
|
|
|
|
index = IndexBook(searchname);
|
|
|
|
|
if (index != -1) {
|
|
|
|
|
if (this->Book_Array->at(index)->getStatue() == true) {
|
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>黹<EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD> <20><> <20>գ<EFBFBD>" << endl;
|
|
|
|
|
cin >> r_year >> r_month >> r_day;
|
|
|
|
|
Date r_data(r_year, r_month, r_day);
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>黹<EFBFBD><E9BBB9><EFBFBD><EFBFBD><EFBFBD>ڵĺϷ<C4BA><CFB7><EFBFBD>
|
|
|
|
|
if (!LegalDate(r_data)) {
|
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD>ڷǷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룡" << endl;
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>
|
|
|
|
|
while (true) {
|
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>黹<EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD> <20><> <20>գ<EFBFBD>" << endl;
|
|
|
|
|
cin >> r_year >> r_month >> r_day;
|
|
|
|
|
r_data = Date(r_year, r_month, r_day);
|
|
|
|
|
if (LegalDate(r_data)) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD>ڷǷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룡" << endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int chargeDay = CntDay(this->Book_Array->at(index)->getDate(), r_data);
|
|
|
|
|
while (chargeDay < 0) {
|
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD>ڷǷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룡" << endl;
|
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>黹<EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD> <20><> <20>գ<EFBFBD>" << endl;
|
|
|
|
|
cin >> r_year >> r_month >> r_day;
|
|
|
|
|
r_data = Date(r_year, r_month, r_day);
|
|
|
|
|
chargeDay = CntDay(this->Book_Array->at(index)->getDate(), r_data);
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
this->Book_Array->at(index)->outTurnin();
|
|
|
|
|
double charge = chargeDay * 0.1;
|
|
|
|
|
this->Book_Array->at(index)->Show_LoanTime();
|
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << chargeDay << "<EFBFBD>죬<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>" << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD>" << charge << "Ԫ" << endl;
|
|
|
|
|
cout << "<EFBFBD>黹<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>ллʹ<EFBFBD>ã<EFBFBD>" << endl;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
cout << "<EFBFBD>ѹ黹<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><EFBFBD>黹<EFBFBD><EFBFBD>" << endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
cout << "<EFBFBD>鼮<EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>黹ʧ<EFBFBD>ܣ<EFBFBD>" << endl;
|
|
|
|
|
}
|
|
|
|
|
system("pause");
|
|
|
|
|
system("cls");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MangerBook::~MangerBook()//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
//dtor
|
|
|
|
|
if (this->Book_Array) {
|
|
|
|
|
this->Book_Array->clear();
|
|
|
|
|
delete[] this->Book_Array;
|
|
|
|
|
this->Book_Array = NULL;//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><C3B6><EFBFBD>ָ<EFBFBD><D6B8>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}
|