📄 booksystem.cpp
字号:
temp->type=ty;
storage++;
j=4 ;
return true;} //完成头节点的创建
int a2=3,b2=3,c2=3; //当头节点已经存在,跳过上面的IF循环,到达这一步
BookSystem*temp4=NULL;
temp4=Search_PandBandA(p,b,m,temp);a2=j; //先判断是否曾经存在该书
if(j==1) //说明曾经存在该书
{(temp4->ID)++;storage++;temp4->type=ty; //这样就不必再创建节点来记录他,直接在以有的节点上,改变他的数量即可
if(temp4->ID==1){temp4->ResearchInsert_Type(temp,temp4);}return true;}//完成
BookSystem*temp1=NULL; //当上面两种情况都不是的话,即要插书既不是头节点,也未曾存在
BookSystem*temp2=NULL;
BookSystem*temp3=NULL;
BookSystem*temp5=NULL;
temp1=Search_PandB(p,b,temp);a2=j; //判断是否要创建坐标系节点
if(a2!=1){InsertMatrix_PandB(p, b,temp);} //若不存在,调用函数创建
temp2=Search_PandA(p,m,temp);b2=j; //判断是否要创建坐标系节点
if(b2!=1){InsertMatrix_PandA(p,m,temp);}
temp3=Search_BandA(b,m,temp);c2=j; //判断是否要创建坐标系节点
if(c2!=1){InsertMatrix_BandA(b,m,temp);}
temp1=Search_Press(p,temp);a2=j; //此时,必能找到,因为就算原来没有,也在上面创建了
temp2=Search_Bookname(b,temp);b2=j;
temp3=Search_Author(m,temp);c2=j;
temp4=Search_PandBandA(p,b,m,temp);a2=j;
if(a2==1) //若能直接找到,说明该节点已经存在
{(temp4->ID)++;storage++;temp4->type=ty;
if(temp4->ID==1){temp4->ResearchInsert_Type(temp,temp4);}return true;}
BookSystem* h;h=new BookSystem; //否则,许创立该节点
//以下是付值过程
h->Set(p,b,m);
h->note[0]=temp1->note[0];h->note[1]=temp2->note[1];h->note[2]=temp3->note[2];
h->ID=1;h->type=ty;temp4->ResearchInsert_Type(temp,h);
//以下要做的是把该节点的三个指针author_next,bookname_next和press_next确定正确的指向
temp4=Search_PandB(p,b,temp); //先确定相同出版社和书名的基节点
while(temp4->note[2]<h->note[2]&&temp4->author_next!=NULL)//沿基节点,按作者顺序把它插入适当的位置
{temp5=temp4;temp4=temp4->author_next;}
if(temp4->note[2]<h->note[2]&&temp4->author_next==NULL)
{temp4->author_next=h;}
else{temp5->author_next=h;h->author_next=temp4;}//完成后,该节点的author_next指针就确定了
temp4=Search_PandA(p,m,temp);//同理,先确定相同出版社和作者的基节点
while(temp4->note[1]<h->note[1]&&temp4->bookname_next!=NULL)
{temp5=temp;temp4=temp4->bookname_next;}
if(temp4->note[1]<h->note[1]&&temp4->bookname_next==NULL)
{temp4->bookname_next=h;}
else{temp5->bookname_next=h;h->bookname_next=temp4;}//完成后,该节点的bookname_next指针就确定了
temp4=Search_BandA(b,m,temp);//同理,先确定相同书名和作者的基节点
while(temp4->note[0]<h->note[0]&&temp4->press_next!=NULL)
{temp5=temp4;temp4=temp4->press_next;}
if(temp4->note[0]<h->note[0]&&temp4->press_next==NULL)
{temp4->press_next=h;}
else{temp5->press_next=h;h->press_next=temp4;}//完成后,该节点的press_next指针就确定了
return true;
}
////////////////////////////////////////////////////////////////////////////////////////////////
void BookSystem::Print_Press(CString p,BookSystem* temp,CListBox &list) //按相同出版社输出
{BookSystem*temp1=NULL;
BookSystem*temp4=NULL;
temp4=temp;
temp1=Search_Press(p,temp); //寻找是否存在该出版社
if(j!=1){ AfxMessageBox("很抱歉,图书馆不存在该出版社的书");}
else{
while(temp1!=NULL) //不等于空,说明存在
{temp4=temp1;temp1=temp1->bookname_next; //在下面的while循环执行完后,相同的出版社,选取下一个书名的底结点
while(temp4!=NULL){if(temp4->ID!=0) //如果该书的数量不等于0,输出该书的信息
{
AfxMessageBox(temp4->bookname+'\n'+temp4->author+'\n'+temp4->press+'\n'+temp4->type);
list.AddString(temp4->bookname+" "+temp4->author+" "+temp4->press+" "+temp4->type);
}
temp4=temp4->author_next;//因为上面已经固定好了出版社和书名,先早的任务是看相同出版社和书名的情况下,查找看有那些不同作者
}
}
}
}
////////////////////////////borrow中的查找函数
void BookSystem::Print_Bookname(CString p,BookSystem* temp,CListBox &list) //按相同的书名来输出
{BookSystem*temp1=NULL;
BookSystem*temp4=NULL;
temp4=temp;
temp1=Search_Bookname(p,temp);
if(j!=1){ AfxMessageBox("很抱歉,图书馆不存在该书名的书");}
else{
while(temp1!=NULL)
{temp4=temp1;;temp1=temp1->press_next;
while(temp4!=NULL){if(temp4->ID!=0){
AfxMessageBox(temp4->bookname+'\n'+temp4->author+'\n'+temp4->press+'\n'+temp4->type);
list.AddString(temp4->bookname+" "+temp4->author+" "+temp4->press+" "+temp4->type);
}
temp4=temp4->author_next;};}
}
}
void BookSystem::Print_Author(CString p,BookSystem* temp,CListBox &list) //按相同的作者输出
{BookSystem*temp1=NULL;
BookSystem*temp4=NULL;
temp4=temp;
temp1=Search_Author(p,temp);
if(j!=1){ AfxMessageBox("很抱歉,图书馆不存在该作者的书");}
else{
while(temp1!=NULL){temp4=temp1;temp1=temp1->press_next;
while(temp4!=NULL){if(temp4->ID!=0){
AfxMessageBox(temp4->bookname+'\n'+temp4->author+'\n'+temp4->press+'\n'+temp4->type);
list.AddString(temp4->bookname+" "+temp4->author+" "+temp4->press+" "+temp4->type);
}
temp4=temp4->bookname_next;};}
}
}
bool BookSystem::Print_Type(CString p,BookSystem* temp,CListBox &list) //按相同的类型输出
{BookSystem*temp1=NULL;
BookSystem*temp4=NULL;
temp4=temp;
while(temp4->type!=p&&temp4->other!=NULL)
{temp4=temp4->other;}
if(temp4->type!=p&&temp4->other==NULL){AfxMessageBox("很抱歉,图书馆不存在该类型的书");;return false;}
while(temp4->type==p)
{
AfxMessageBox(temp4->bookname+'\n'+temp4->author+'\n'+temp4->press+'\n'+temp4->type);
list.AddString(temp4->bookname+" "+temp4->author+" "+temp4->press+" "+temp4->type);
if(temp4->same==NULL){return true;};
temp4=temp4->same;}
return true;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
void BookSystem::Print_PandB(CString p, CString b, BookSystem* temp,CListBox &list) //按出版社和书名来输出
{BookSystem*temp4=NULL;
temp4=Search_PandB(p,b,temp);
if(j!=1){ AfxMessageBox("很抱歉,图书馆不存在符合条件的书");}
else{
if(j==1){while(temp4!=NULL){if(temp4->ID!=0){
AfxMessageBox(temp4->bookname+'\n'+temp4->author+'\n'+temp4->press+'\n'+temp4->type);
list.AddString(temp4->bookname+" "+temp4->author+" "+temp4->press+" "+temp4->type);
}
temp4=temp4->author_next;};}
}
}
void BookSystem::Print_PandA(CString p, CString m, BookSystem* temp,CListBox &list) //按出版社和作者名来输出
{BookSystem*temp4=NULL;
temp4=Search_PandA(p,m,temp);
if(j!=1){ AfxMessageBox("很抱歉,图书馆不存在符合条件的书");}
else{
if(j==1){while(temp4!=NULL){if(temp4->ID!=0){
AfxMessageBox(temp4->bookname+'\n'+temp4->author+'\n'+temp4->press+'\n'+temp4->type);
list.AddString(temp4->bookname+" "+temp4->author+" "+temp4->press+" "+temp4->type);
}
temp4=temp4->bookname_next;};}
}
}
void BookSystem::Print_BandA(CString b, CString m , BookSystem* temp,CListBox &list) //按书名和作者名来输出
{BookSystem*temp4=NULL;
temp4=Search_BandA(b,m,temp);
if(j!=1){ AfxMessageBox("很抱歉,图书馆不存在符合条件的书");}
else{
if(j==1){while(temp4!=NULL){if(temp4->ID!=0){
AfxMessageBox(temp4->bookname+'\n'+temp4->author+'\n'+temp4->press+'\n'+temp4->type);
list.AddString(temp4->bookname+" "+temp4->author+" "+temp4->press+" "+temp4->type);
}
temp4=temp4->press_next;};}
}
}
void BookSystem::Print_PandBandA(CString p, CString b, CString m , BookSystem* temp,CListBox &list) //按出版社,书名和作者名来输出
{BookSystem*temp4=NULL;
temp4=Search_PandBandA(p,b,m,temp);
if(j!=1){ AfxMessageBox("很抱歉,图书馆不存在符合条件的书");}
else{
if(j==1){
AfxMessageBox(temp4->bookname+'\n'+temp4->author+'\n'+temp4->press+'\n'+temp4->type);
list.AddString(temp4->bookname+" "+temp4->author+" "+temp4->press+" "+temp4->type);
}
}
}
/////////////////////////////////decrease和reinforce的查找函数
BookSystem * BookSystem::Print_Press(CString p,BookSystem* temp) //按相同出版社输出
{BookSystem*temp1=NULL;
BookSystem*temp4=NULL;
temp1=Search_Press(p,temp); //寻找是否存在该出版社
if(j!=1){ AfxMessageBox("很抱歉,图书馆不存在符合条件的书");return temp4;}
temp4=temp;
while(temp1!=NULL) //不等于空,说明存在
{temp4=temp1;temp1=temp1->bookname_next; //在下面的while循环执行完后,相同的出版社,选取下一个书名的底结点
while(temp4!=NULL){if(temp4->ID!=0) //如果该书的数量不等于0,输出该书的信息
{
AfxMessageBox(temp4->bookname+'\n'+temp4->author+'\n'+temp4->press+'\n'+temp4->type);
return temp4;
}
temp4=temp4->author_next;//因为上面已经固定好了出版社和书名,先早的任务是看相同出版社和书名的情况下,查找看有那些不同作者
}
}
}
BookSystem * BookSystem::Print_Bookname(CString p,BookSystem* temp) //按相同的书名来输出
{BookSystem*temp1=NULL;
BookSystem*temp4=NULL;
temp1=Search_Bookname(p,temp);
if(j!=1){ AfxMessageBox("很抱歉,图书馆不存在符合条件的书");return temp4;}
temp4=temp;
while(temp1!=NULL)
{temp4=temp1;;temp1=temp1->press_next;
while(temp4!=NULL){if(temp4->ID!=0){
AfxMessageBox(temp4->bookname+'\n'+temp4->author+'\n'+temp4->press+'\n'+temp4->type);
return temp4;
}
temp4=temp4->author_next;};}
}
BookSystem * BookSystem::Print_Author(CString p,BookSystem* temp) //按相同的作者输出
{BookSystem*temp1=NULL;
BookSystem*temp4=NULL;
temp1=Search_Author(p,temp);
if(j!=1){ AfxMessageBox("很抱歉,图书馆不存在符合条件的书");return temp4;}
temp4=temp;
while(temp1!=NULL){temp4=temp1;temp1=temp1->press_next;
while(temp4!=NULL){if(temp4->ID!=0){
AfxMessageBox(temp4->bookname+'\n'+temp4->author+'\n'+temp4->press+'\n'+temp4->type);
return temp4;
}
temp4=temp4->bookname_next;};}
}
bool BookSystem::Print_Type(CString p,BookSystem* temp) //按相同的类型输出
{
BookSystem*temp1=NULL;
BookSystem*temp4=NULL;
temp4=temp;
while(temp4->type!=p&&temp4->other!=NULL)
{temp4=temp4->other;}
if(temp4->type!=p&&temp4->other==NULL){;return false;}
while(temp4->type==p)
{
AfxMessageBox(temp4->bookname+'\n'+temp4->author+'\n'+temp4->press+'\n'+temp4->type);
//return temp4;
if(temp4->same==NULL){return true;};
temp4=temp4->same;}
return true;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
BookSystem * BookSystem::Print_PandB(CString p, CString b, BookSystem* temp) //按出版社和书名来输出
{BookSystem*temp4=NULL;
temp4=Search_PandB(p,b,temp);
if(j==1){while(temp4!=NULL){if(temp4->ID!=0){
AfxMessageBox(temp4->bookname+'\n'+temp4->author+'\n'+temp4->press+'\n'+temp4->type);
return temp4;
}
temp4=temp4->author_next;};}
}
BookSystem * BookSystem::Print_PandA(CString p, CString m, BookSystem* temp) //按出版社和作者名来输出
{BookSystem*temp4=NULL;
temp4=Search_PandA(p,m,temp);
if(j==1){while(temp4!=NULL){if(temp4->ID!=0){
AfxMessageBox(temp4->bookname+'\n'+temp4->author+'\n'+temp4->press+'\n'+temp4->type);
return temp4;
}
temp4=temp4->bookname_next;};}
}
BookSystem * BookSystem::Print_BandA(CString b, CString m , BookSystem* temp) //按书名和作者名来输出
{BookSystem*temp4=NULL;
temp4=Search_BandA(b,m,temp);
if(j==1){while(temp4!=NULL){if(temp4->ID!=0){
AfxMessageBox(temp4->bookname+'\n'+temp4->author+'\n'+temp4->press+'\n'+temp4->type);
return temp4;
}
temp4=temp4->press_next;};}
}
BookSystem * BookSystem::Print_PandBandA(CString p, CString b, CString m , BookSystem* temp) //按出版社,书名和作者名来输出
{BookSystem*temp4=NULL;
temp4=Search_PandBandA(p,b,m,temp);
if(j==1){
AfxMessageBox(temp4->bookname+'\n'+temp4->author+'\n'+temp4->press+'\n'+temp4->type);
return temp4;
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
bool BookSystem::Borrowbookname(CString p, CString b, CString m,BookSystem*temp)
{BookSystem* temp1=NULL;//cout<<"Borrowbookname"<<endl;
temp1=Search_PandBandA(p,b,m,temp);
if(j==1){//cout<<"This bookname is exist"<<endl;
if(temp1->ID>=1){(temp1->ID)--;//cout<<"Borrow bookname succeed"<<endl;return true;
}
}
return false;
}
bool BookSystem::Returnbookname(CString p, CString b, CString m,BookSystem*temp)
{BookSystem* temp1=NULL;
temp1=Search_PandBandA(p,b,m,temp);
if(j==1){(temp1->ID)++;
}
return false;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -