本文給大家分享的是使用C++實現簡單的圖書管理系統的代碼,本系統采用了面向對象的程序設計方法,感興趣的小伙伴可以參考下。
今天再為大家介紹另一個常用的管理系統——圖書管理系統,希望大家可以親自動手實踐一下,下面就與大家一起分享我的勞動成果。
圖書信息包括:登錄號、書名、作者名、分類號、出版單位、出版時間、價格等。試設計一圖書信息管理系統,使之能提供以下功能:
(1)圖書信息錄入功能(圖書信息用文件保存)
(2)圖書信息瀏覽功能
(3)查詢和排序功能:(至少一種查詢方式)
.按書名查詢
.按作者名查詢
(4)圖書信息的刪除與修改
分享代碼如下
- #include<iostream.h>
- #include<conio.h> //控制臺數據輸入輸出的函數
- #include<fstream.h>//文件流
- #include<iomanip.h> //控制數據輸出格式
- #include<string.h>
- const int Maxr=100 ;//最多的讀者數
- const int Maxb=100; //最多的圖書數
- const int Maxbor=5; //每位讀者最多借的書
- class Book
- {//圖書類,實現對圖書的描述,圖書的編號,書名,借出,還入等功能
- private:
- int tag; //刪除標記 1:已刪 0:未刪
- int no; //圖書編號
- char name[20]; //書名
- char author[20];//作者
- char fenlei[20];//分類號
- char cbs[20]; //出版社
- int cbtime;//出版時間
- double bookprice;//圖書價格
- int onshelf; //是否再架 1:再架 2:已借
- public:
- Book(){;}
- char *getname()
- {//獲取書名
- return name;
- }
- char *getauthorname()
- {//獲取作者名
- return author;
- }
- char *getfenlei()
- {//獲取分類號
- return fenlei;
- }
- char *getcbsname()
- {//獲取出版社名
- return cbs;
- }
- int getcbtime()
- {//獲取出版時間
- return cbtime;
- }
- double getbookprice()
- {//獲取圖書價格
- return bookprice;
- }
- int getno()
- {//獲取圖書編號
- return no;
- }
- int gettag()
- {//獲取刪除標記
- return tag;
- }
- void setname(char na[])
- {//設置書名
- strcpy(name,na);
- }
- void setauthorname(char aa[])
- {//設置作者名
- strcpy(author,aa);
- }
- void setfenlei(char fe[])
- {//設置分類號
- strcpy(fenlei,fe);
- }
- void setcbs(char ca[])
- {//設置出版社
- strcpy(cbs,ca);
- }
- void setcbtime(int time)
- {//設置時間
- cbtime=time;
- }
- void setbookprice(double price)
- {//設置圖書價格
- bookprice=price;
- }
- void setonshelf(int oa)
- {
- onshelf=oa;
- }
- void delbook()
- {//刪除圖書
- char i;
- cout<<"確定刪除嗎?Y/N ?"<<endl;
- cin>>i;
- if(i=='y'||i=='Y')
- tag=1;
- }
- void addbook(int n,char *na,char *aa,char *fe,char *ca,int time,double price,int oa)
- {//增加圖書
- tag=0;
- no=n;
- strcpy(name,na);
- strcpy(author,aa);
- strcpy(cbs,ca);
- strcpy(fenlei,fe);
- cbtime=time;
- bookprice=price;
- onshelf=oa;
- }
- int borrowbook()
- {//借書操作
- if (onshelf>0)
- {
- onshelf--;
- return 1;
- }
- return 0;
- }
- void retbook()
- {//還書操作
- onshelf++;
- }
- void disp()
- {//輸出圖書
- cout<<setw(3)<<no<<setw(10)<<name<<setw(10)<<author<<setw(10)<<fenlei<<setw(15)<<cbs<<setw(10)<<cbtime<<setw(10)<<bookprice<<setw(10)<<onshelf<<endl;
- }
- };
- class BDatabase
- {//圖書庫類,實現對圖書的維護,查找,刪除等
- private:
- int top; //圖書記錄指針
- Book book[Maxb]; //圖書記錄
- public:
- BDatabase()
- {//構造函數,將book.txt讀到book[]中
- Book b;
- top=-1;
- fstream file("book.txt",ios::in);
- while (1)
- {
- file.read((char *)&b,sizeof(b));
- if (!file)
- break;
- top++;
- book[top]=b;
- }
- file.close();
- }
- void clear()
- {//全刪
- char i;
- cout<<"確定全部刪除嗎?Y/N ?"<<endl;
- cin>>i;
- if(i=='y'||i=='Y')
- top=-1;
- }
- int addbook(int n,char *na,char *aa,char *fe,char *ca,int time, double price,int oa)
- {//增加圖書
- Book *p=query1(n);
- if (NULL==p)
- {
- top++;
- book[top].addbook(n,na,aa,fe,ca,time,price,oa);
- return 1;
- }
- return 0;
- }
- Book *query1(int bookid)
- {//按編號查找圖書
- for(int i=0;i<=top;i++)
- if(book[i].getno()==bookid &&book[i].gettag()==0)
- {
- return &book[i];
- }
- return NULL;
- }
- Book *query2(char a[])
- {//按書名查找圖書
- Book *e;
- int r=0;
- for(int i=0;i<=top;i++)
- if(strcmp(book[i].getname(),a)==0 &&book[i].gettag()==0)
- {
- if(r==0)
- cout<<setw(3)<<"編號"<<setw(10)<<"書名"<<setw(10)<<"作者"<<setw(10)<<"分類號"<<setw(15)<<"出版社"<<setw(10)<<"出版時間"<<setw(10)<<"圖書價格"<<setw(10)<<"存量"<<endl;
- e=&book[i];
- e->disp();
- r++;
- }
- if(r==0)
- cout<<"找不到該書!"<<endl;
- return NULL;
- }
- Book *query3(char a[])
- {//按作者查找圖書
- Book *e;
- int r=0;
- for(int i=0;i<=top;i++)
- if(strcmp(book[i].getauthorname(),a)==0 &&book[i].gettag()==0)
- {
- if(r==0)
- cout<<setw(3)<<"編號"<<setw(10)<<"書名"<<setw(10)<<"作者"<<setw(10)<<"分類號"<<setw(15)<<"出版社"<<setw(10)<<"出版時間"<<setw(10)<<"圖書價格"<<setw(10)<<"存量"<<endl;
- e=&book[i];
- e->disp();
- r++;
- }
- if(r==0)
- cout<<"找不到該書!"<<endl;
- return NULL;
- }
- Book *query4(char a[])
- {//按出版社查找圖書
- Book *e;
- int r=0;
- for (int i=0;i<=top;i++)
- if (strcmp(book[i].getcbsname(),a)==0 &&book[i].gettag()==0)
- {
- if(r==0)cout<<setw(3)<<"編號"<<setw(10)<<"書名"<<setw(10)<<"作者"<<setw(10)<<"分類號"<<setw(15)<<"出版社"<<setw(10)<<"出版時間"<<setw(10)<<"圖書價格"<<setw(10)<<"存量"<<endl;
- e=&book[i];
- e->disp();
- r++;
- }
- if(r==0)
- cout<<"找不到該書!"<<endl;
- return NULL;
- }
- void bookdata(); //圖書庫信息
- void disp()
- {
- for(int i=0;i<=top;i++)
- if(book[i].gettag()==0)
- book[i].disp();
- }
- ~BDatabase()
- {//析構函數,將book[]寫到book.txt文件中
- fstream file("book.txt",ios::out);
- for(int i=0;i<=top;i++)
- if(book[i].gettag()==0)
- file.write((char *)&book[i],sizeof(book[i]));
- file.close();
- }
- };
- void BDatabase::bookdata()
- {
- char choice3;
- char bname[40];//書名
- char auname[40];//作者名
- char bfenlei[40];//分類號
- char cname[40];//出版社
- int time;//出版時間
- double price;//價格
- char ch;
- int choice4;
- int bookid;
- int bookod;
- Book *b;
- while (choice3!='0')
- {
- cout<<"/n/t/t/t** 圖 書 信 息 **/n"<<endl;
- cout<<"/t/t/t** 1.新 增 **"<<endl;
- cout<<"/t/t/t** 2.更 改 **"<<endl;
- cout<<"/t/t/t** 3.刪 除 **"<<endl;
- cout<<"/t/t/t** 4.查 找 **"<<endl;
- cout<<"/t/t/t** 5.顯 示 **"<<endl;
- cout<<"/t/t/t** 6.全 刪 **"<<endl;
- cout<<"/t/t/t** 0.返 回 **"<<endl;
- cout<<"/t/t/t 請選擇:";
- cin>>choice3;
- switch(choice3)
- {
- case '1':
- cout<<"請輸入新書編號:";
- cin>>bookid;
- b=query1(bookid);
- if(b!=NULL)
- {
- cout<<"該編號已經存在,不能添加!"<<endl;
- break;
- }
- cout<<"請輸入新書書名:";
- cin>>bname;
- cout<<"請輸入新書作者名:";
- cin>>auname;
- cout<<"請輸入新書分類號:";
- cin>>bfenlei;
- cout<<"請輸入新書出版社:";
- cin>>cname;
- cout<<"請輸入新書出版時間:";
- cin>>time;
- cout<<"請輸入圖書價格:";
- cin>>price;
- cout<<"請輸入新書數量:";
- cin>>bookod;
- addbook(bookid,bname,auname,bfenlei,cname,time,price,bookod);
- char choice2;
- {
- cout<<"/n/t/t/t** 是 否 保 存 Y/N ?**/n"<<endl;
- cout<<"/t/t/t** 1. Y 保 存 **"<<endl;
- cout<<"/t/t/t** 0. N 不 保 存 **"<<endl;
- cout<<"/t/t/t 請 選 擇: ";
- cin>>choice2;
- switch(choice2)
- {
- case '1':
- cout<<"添加圖書成功!";
- break;
- case '0':
- break;
- }
- }
- getch();
- break;
- case '2':
- cout<<"請輸入圖書編號:";
- cin>>bookid;
- b=query1(bookid);
- if(b==NULL)
- {
- cout<<"該圖書不存在! "<<endl;
- break;
- }
- cout<<"該圖書的信息是:"<<endl;
- cout<<setw(3)<<"編號"<<setw(10)<<"書名"<<setw(10)<<"作者"<<setw(10)<<"分類號"<<setw(15)<<"出版社"<<setw(10)<<"出版時間"<<setw(10)<<"圖書價格"<<setw(10)<<"存量"<<endl;
- b->disp();
- cout<<"是否修改?( y/n ):";
- cin>>ch;
- if(ch=='y'||ch=='Y')
- {int a;
- cout<<"/n/t/t/t** 圖 書 修 改 **/n"<<endl;
- cout<<"/t/t/t** 1.修 改 書 名 **"<<endl;
- cout<<"/t/t/t** 2.修 改 作 者 **"<<endl;
- cout<<"/t/t/t** 3.修 改 分 類 號 **"<<endl;
- cout<<"/t/t/t** 4.修 改 出 版 社 **"<<endl;
- cout<<"/t/t/t** 5.修 改 出 版 時 間**"<<endl;
- cout<<"/t/t/t** 6.修 改 圖 書 價 格**"<<endl;
- cout<<"/t/t/t** 7.修 改 圖 書 數 量**"<<endl;
- cout<<"/t/t/t** 0.返 回 **"<<endl;
- cout<<"/t/t/t 請選擇:";
- cin>>a;
- switch(a)
- {
- case 1: cout<<"請輸入新的書名:";
- cin>>bname; b->setname(bname); break;
- case 2: cout<<"請輸入新的作者:";
- cin>>auname; b->setauthorname(auname); break;
- case 3: cout<<"請輸入新的分類號:";
- cin>>bfenlei; b->setfenlei(bfenlei); break;
- case 4: cout<<"請輸入新書出版社:";
- cin>>cname; b->setcbs(cname); break;
- case 5: cout<<"請輸入新書出版時間:";
- cin>>time;b->setcbtime(time); break;
- case 6: cout<<"請輸入圖書價格:";
- cin>>price; b->setbookprice(price); break;
- case 7: cout<<"請輸入新的存量:";
- cin>>bookod; b->setonshelf(bookod); break;
- case 0: break;
- }
- }
- cout<<"修改圖書成功!";
- getch();
- break;
- case '3':
- cout<<"請輸入圖書編號:";
- cin>>bookid;
- b=query1(bookid);
- if(b==NULL)
- {
- cout<<"該圖書不存在,無法刪除!"<<endl;
- break;
- }
- b->delbook();
- cout<<"刪除成功!";
- getch();
- break;
- case '4':
- cout<<"/n/t/t/t** 1.按圖書編號查找 **"<<endl;
- cout<<"/t/t/t** 2.按圖書書名查找 **"<<endl;
- cout<<"/t/t/t** 3.按圖書作者查找 **"<<endl;
- cout<<"/t/t/t** 4.按圖書出版社查找**"<<endl;
- cout<<"/t/t/t** 0. 返 回 **"<<endl;
- cout<<"/t/t/t 請選擇:";
- cin>>choice4;
- switch(choice4)
- {
- case 1:
- cout<<"請輸入圖書編號:";
- cin>>bookid;
- b=query1(bookid);
- if(b==NULL)
- {
- cout<<"該圖書不存在!";
- break;
- }
- cout<<setw(3)<<"編號"<<setw(10)<<"書名"<<setw(10)<<"作者"<<setw(10)<<"分類號"<<setw(15)<<"出版社"<<setw(10)<<"出版時間"<<setw(10)<<"圖書價格"<<setw(10)<<"存量"<<endl;
- b->disp();
- break;
- case 2:
- cout<<"請輸入圖書書名:";
- cin>>bname;
- b=query2(bname);
- break;
- case 3:
- cout<<"請輸入圖書作者:";
- cin>>auname;
- b=query3(auname);
- break;
- case 4:
- cout<<"請輸入圖書出版社:";
- cin>>cname;
- b=query4(cname);
- break;
- case 0:
- break;
- }
- break;
- case '5':
- cout<<setw(3)<<"編號"<<setw(10)<<"書名"<<setw(10)<<"作者"<<setw(10)<<"分類號"<<setw(15)<<"出版社"<<setw(10)<<"出版時間"<<setw(10)<<"圖書價格"<<setw(10)<<"存量"<<endl;
- disp();
- getch();
- break;
- case '6':
- clear();
- break;
- default:
- break;
- }
- }
- }
- class Reader
- {//讀者的信息描述
- private:
- int tag; //刪除標記 1表示已刪 0表示未刪
- int no; //讀者編號
- char name[20]; //讀者姓名
- int borbook[Maxbor]; //所借圖書
- public:
- Reader() //構造函數
- { ; }
- friend ostream &operator<<(ostream &output,Reader &rd)
- {output<<rd.no;
- output<<" ";
- output<<endl;
- return output;}
- char *getname()
- {//獲取姓名
- return name;
- }
- int gettag()
- {//獲取刪除標記
- return tag;
- }
- int getno()
- {//獲取讀者編號
- return no;
- }
- void setname(char na[])
- {//設置姓名
- strcpy(name,na);
- }
- void delbook()
- {//設置刪除標記 1:已刪 0:未刪
- char i;
- cout<<"確定刪除嗎?Y/N ?"<<endl;
- cin>>i;
- if(i=='y'||i=='Y')
- tag=1;
- }
- void addreader(int n,char *na)
- {//增加讀者
- tag=0;
- no=n;
- strcpy(name,na);
- for(int i=0;i<Maxbor;i++)
- borbook[i]=0;
- }
- void borrowbook(int bookid)
- {//借書操作
- for(int i=0;i<Maxbor;i++)
- {
- if (borbook[i]==0)
- {
- borbook[i]=bookid;
- return ;
- }
- }
- }
- int retbook(int bookid)
- {//還書操作
- for(int i=0;i<Maxbor;i++)
- {
- if(borbook[i]==bookid)
- {
- borbook[i]=0;
- cout<<"還書成功!"<<endl;
- return 1;
- }
- }
- cout<<"未借該書,還書失敗!"<<endl;
- return 0;
- }
- void disp()
- {//讀出讀者信息
- int have=0;
- int bz=0;
- cout<<setw(5)<<no<<setw(21)<<name<<setw(15);
- for(int i=0;i<Maxbor;i++)
- if(borbook[i]!=0)
- {
- if(bz==0)
- {
- have=1;
- cout<<"["<<borbook[i]<<"]/t/t"<<endl;
- bz++;
- }
- else
- {
- cout<<"/r/t/t/t/t/t""["<<borbook[i]<<"]/t/t"<<setw(15)<<endl;
- }
- }
- if(have==0)
- cout<<"/t 還未借書"<<endl;
- }
- };
- class RDatabase
- {//讀者類庫,實現建立讀者的個人資料
- private:
- int top; //讀者記錄指針
- Reader read[Maxr]; //讀者記錄
- public:
- RDatabase()
- {//構造函數,將reader.txt讀到read[]中
- Reader s;
- top=-1;
- fstream file("reader.txt",ios::in); //打開一個輸入文件
- while (1)
- {
- file.read((char *)&s,sizeof(s));
- if (!file)
- break;
- top++;
- read[top]=s;
- }
- file.close(); //關閉 reader.txt 文件
- }
- void clear()
- {//刪除所有讀者信息
- char i;
- cout<<"確定全部刪除嗎?Y/N ?"<<endl;
- cin>>i;
- if(i=='y'||i=='Y')
- top=-1;
- }
- int addreader(int n,char *na)
- {//添加讀者時先查找是否存在
- Reader *p=queryid(n);
- if (p==NULL)
- {
- top++;
- read[top].addreader(n,na);
- return 1;
- }
- else
- cout<<"該編號已經存在!";
- return 0;
- }
- Reader *queryid(int readerid)
- {//按讀者編號查找
- for (int i=0;i<=top;i++)
- if (read[i].getno()==readerid&&read[i].gettag()==0)
- {
- return &read[i];
- }
- return NULL;
- }
- Reader *queryname(char readername[10])
- {//按讀者姓名查找
- for (int i=0;i<=top;i++)
- if (strcmp(read[i].getname(),readername)==0 && read[i].gettag()==0)
- {
- return &read[i];
- }
- return NULL;
- }
- void disp()
- {//輸出所有讀者信息
- for(int i=0;i<=top;i++)
- if (read[i].gettag()==0)
- read[i].disp();
- }
- void readerdata(); //讀者庫信息
- ~RDatabase()
- {//析構函數,將read[]寫到reader.txt文件中
- fstream file("reader.txt",ios::out);
- for (int i=0;i<=top;i++)
- if (read[i].gettag()==0)
- file.write((char *)&read[i],sizeof(read[i]));
- file.close();
- }
- };
- void RDatabase::readerdata()
- {
- char choice1;
- char rname[20];
- int readerid;
- char readername[10];
- int choice2;
- Reader *r;
- while(choice1!='0')
- {
- cout<<"/n/t/t/t** 讀 者 信 息 **/n"<<endl;
- cout<<"/t/t/t** 1. 新 增 **"<<endl;
- cout<<"/t/t/t** 2. 更 改 **"<<endl;
- cout<<"/t/t/t** 3. 刪 除 **"<<endl;
- cout<<"/t/t/t** 4. 查 找 **"<<endl;
- cout<<"/t/t/t** 5. 顯 示 **"<<endl;
- cout<<"/t/t/t** 6. 全 刪 **"<<endl;
- cout<<"/t/t/t** 0. 返 回 **"<<endl;
- cout<<"/t/t/t 請選擇:";
- cin>>choice1;
- switch(choice1)
- {
- case '1':
- cout<<"請輸入讀者編號:";
- cin>>readerid;
- cout<<"請輸入讀者姓名:";
- cin>>rname;
- addreader(readerid,rname);
- cout<<"添加讀者成功!"<<endl;
- getch();
- break;
- case '2':
- cout<<"請輸入讀者編號:";
- cin>>readerid;
- r=queryid(readerid);
- if(r==NULL)
- {
- cout<<"該讀者不存在! "<<endl;
- break;
- }
- cout<<"請輸入新的姓名:";
- cin>>rname;
- r->setname(rname);
- cout<<"修改讀者成功!"<<endl;
- getch();
- break;
- case '3':
- cout<<"請輸入讀者編號:";
- cin>>readerid;
- r=queryid(readerid);
- if(r==NULL)
- {
- cout<<"該讀者不存在!" << endl;
- break;
- }
- r->delbook();
- cout<<"刪除成功!"<<endl;
- getch();
- break;
- case '4':
- cout<<"/n/t/t/t** 1.按讀者編號查找 **"<<endl;
- cout<<"/t/t/t** 2.按讀者姓名查找 **"<<endl;
- cout<<"/t/t/t** 0.返 回 **"<<endl;
- cout<<"/t/t/t 請選擇:";
- cin>>choice2;
- switch(choice2)
- {
- case 1:
- cout<<"請輸入讀者編號:";
- cin>>readerid;
- r=queryid(readerid);
- if(r==NULL)
- {
- cout<<"該讀者不存在!"<< endl;
- break;
- }
- cout<<setw(10)<<"讀者編號"<<setw(17)<<"讀者姓名"<<setw(20)<<"已借書編號"<<endl;
- r->disp();
- break;
- case 2:
- cout<<"請輸入讀者姓名:";
- cin>>readername;
- r=queryname(readername);
- if(r==NULL)
- {
- cout<<"該讀者不存在!"<<endl;
- break;
- }
- cout<<setw(10)<<"讀者編號"<<setw(17)<<"讀者姓名"<<setw(20)<<"已借書編號"<<endl;
- r->disp();
- break;
- case 0:
- break;
- }
- break;
- case '5':
- cout<<setw(10)<<"讀者編號"<<setw(17)<<"讀者姓名"<<setw(20)<<"已借書編號"<<endl;
- disp();
- getch();
- break;
- case '6':
- clear();
- break;
- default:
- break;
- }
- }
- }
- class maindesk //實現程序的主界面
- {
- char choice5;
- char choice2;
- double xh,mm;
- int bookid,readerid;
- RDatabase ReaderDB;
- Reader *r;
- BDatabase BookDB;
- Book *b;
- public:
- maindesk() {;}
- int denglu()
- {
- int k=0;
- cout<<"/n/t/t/t 歡 迎 光 臨 圖 書 館 管 理 系 統!"<<endl;
- cout<<"/t/t/t 您 共 有 3 次 登 陸 機 會"<<endl;
- while(choice2!='0')
- { ++k;
- cout<<"/t/t/t ** 1. 登 錄 **"<<endl;
- cout<<"/t/t/t ** 0. 退 出 **"<<endl;
- cout<<"/t/t/t 請 選 擇: ";
- cin>>choice2;
- switch (choice2)
- {
- case '1':
- cout<<"請輸入學號和密碼"<<endl;
- cin>>xh>>mm;
- if((xh>=138325039)&&(xh<=138325039)&&(xh==mm))
- {
- cout<<"登錄成功"<<endl;
- enterdesk();
- }
- if((xh<138325039)||(xh>138325039)||(xh!=mm))
- {cout<<"登錄失?。耗€有"<<3-k<<"次登陸機會"<<endl;
- if(k>=3)
- {
- cout<<"您已超過登錄次數上限,系統自動退出!"<<endl;
- return 1;
- }
- continue;
- }
- break;
- case '0':
- break;}
- return 1;
- }
- return 0;
- }
- void enterdesk()
- {
- while(choice5!='0')
- {
- cout<<"/n/t/t/t**** 圖 書 管 理 系 統****/n/n";
- cout<<"/t/t/t** 1.圖 書 信 息 **"<<endl;
- cout<<"/t/t/t** 2.讀 者 信 息 **"<<endl;
- cout<<"/t/t/t** 3.借 閱 圖 書 **"<<endl;
- cout<<"/t/t/t** 4.歸 還 圖 書 **"<<endl;
- cout<<"/t/t/t** 0. 退 出 **"<<endl;
- cout<<"/t/t/t 請選擇:";
- cin>>choice5;
- switch (choice5)
- {
- case '1':
- BookDB.bookdata();
- break;
- case '2':
- ReaderDB.readerdata();
- break;
- case '3':
- cout<<"/t/t/t/t借書操作"<<endl;
- cout<<"請輸入借書讀者編號:";
- cin>>readerid;
- r=ReaderDB.queryid(readerid);
- if(NULL==r)
- {//按編號查找是否有該讀者
- cout<<"不存在該讀者,不能借書!"<<endl;
- break;
- }
- cout<<"請輸入要借圖書編號:";
- cin>>bookid;
- b=BookDB.query1(bookid);
- if(b==NULL)
- {//按編號查找是否有該圖書
- cout<<"不存在該圖書,不能借書!"<<endl;
- break;
- }
- if(b->borrowbook()==0)
- {
- cout<<"該圖書已借完,不能借書!"<<endl;
- break;
- }
- cout<<"讀者借書成功!"<<endl;
- r->borrowbook(b->getno());
- break;
- case '4':
- cout<<"/t/t/t/t還書操作"<<endl;
- cout<<"請輸入還書讀者編號:";
- cin>>readerid;
- r=ReaderDB.queryid(readerid);
- if(r==NULL)
- {
- cout<<"不存在該讀者,不能還書"<<endl;
- break;
- }
- cout<<"請輸入要歸還圖書編號:";
- cin>>bookid;
- b=BookDB.query1(bookid);
- if(b==NULL)
- {
- cout<<"不存在該圖書,不能還書"<<endl;
- break;
- }
- b->retbook();
- r->retbook(b->getno());
- break;
- case '0':
- break;
- default:
- break;
- }
- }
- }
- };
- void main() //主函數
- {
- maindesk yourDesk;
- if(yourDesk.denglu())
- cout<<"/t/t 謝 謝 使 用 , 再 見 !"<<endl;
- }
運行效果圖:
以上就是本文的全部內容,希望大家可以喜歡,抓緊動手實現吧
新聞熱點
疑難解答