//这个是main.cpp中的代码
#include <iostream>
#include <iomanip>//作用是调用setw()函数
#include <string>
#include <stdlib.h>//使用exit()函数
#include <fstream>//使用文件输入输出流
#include "article.h"
//#include "article.cpp"
#include "book.h"
#include "picture.h"
#include "disk.h"
#include "add.h"
#include "del.h"
using namespace std;
int main()
{
int i;//用于菜单功能
int j;//存放物品的编号
string str;//存放物品的标题
//以下9行程序为建立链表做准备工作
struct book * bhead,*bcurrent;
struct disk * dhead,*dcurrent;
struct picture *phead,*pcurrent;
bhead=bcurrent=NULL;
dhead=dcurrent=NULL;
phead=pcurrent=NULL;
bhead=initbook();
dhead=initdisk();
phead=initpicture();
while(1)
{
cout<<endl;
cout<<"*****************************媒体库管理系统*************************************";
cout<<setw(40)<<"1、添加物品"<<endl;
cout<<setw(40)<<"2、显示物品"<<endl;
cout<<setw(40)<<"3、查询物品"<<endl;
cout<<setw(40)<<"4、统计物品"<<endl;
cout<<setw(40)<<"5、删除物品"<<endl;
cout<<setw(40)<<"6、编辑物品"<<endl;
cout<<setw(36)<<"7、清屏"<<endl;
cout<<setw(36)<<"8、退出"<<endl;
cout<<"********************************************************************************";
cin>>i;
switch(i)
{
case 1:
cout<<"********************************************************************************";
cout<<setw(40)<<"1、添加书的信息"<<endl;
cout<<setw(40)<<"2、添加光盘信息"<<endl;
cout<<setw(40)<<"3、添加图画信息"<<endl;
cout<<"********************************************************************************";
cin>>i;
if(i==1)
bhead=addbook(bhead);
else if(i==2)
dhead=adddisk(dhead);
else if(i==3)
phead=addpicture(phead);
else
{
cout<<"输入有误,返回主目录!"<<endl;
}
break;
case 2:
cout<<"********************************************************************************";
cout<<setw(40)<<"1、显示书的信息"<<endl;
cout<<setw(40)<<"2、显示光盘信息"<<endl;
cout<<setw(40)<<"3、显示图画信息"<<endl;
cout<<"********************************************************************************";
cin>>i;
if(i==1)
{
if(bhead!=NULL)
{
bcurrent=bhead;
while(bcurrent!=NULL)
{
bcurrent->bk->showbook();
bcurrent=bcurrent->next;
}
}
else cout<<"无图书信息!"<<endl;
}
else if(i==2)
{
if(dhead!=NULL)
{
dcurrent=dhead;
while(dcurrent!=NULL)
{
dcurrent->dk->showdisk();
dcurrent=dcurrent->next;
}
}
else cout<<"无光盘信息!"<<endl;
}
else if(i==3)
{
if(phead!=NULL)
{
pcurrent=phead;
while(pcurrent!=NULL)
{
pcurrent->pe->showpicture();
pcurrent=pcurrent->next;
}
}
else cout<<"无图画信息!"<<endl;
}
else
{
cout<<"输入错误,返回主目录!"<<endl;
}
break;
case 3:
cout<<"********************************************************************************";
cout<<setw(40)<<"1、按标题查询"<<endl;
cout<<setw(40)<<"2、按编号查询"<<endl;
cout<<setw(40)<<"3、按类别查询"<<endl;
cout<<"********************************************************************************";
cin>>i;
if(i==1)
{
cout<<"请输入物品的标题:"<<endl;
cin>>str;
pcurrent=phead;
while(pcurrent!=NULL)
{
if(pcurrent->pe->searchtitle(str))
{
cout<<setw(40)<<"图画中的信息如下所示:"<<endl;
pcurrent->pe->showpicture();
break;
}
else
pcurrent=pcurrent->next;
}
if(pcurrent==NULL)
{
cout<<setw(40)<<"图画中无此信息!"<<endl;
}
dcurrent=dhead;
while(dcurrent!=NULL)
{
if(dcurrent->dk->searchtitle(str))
{
cout<<setw(40)<<"光盘中的信息如下所示:"<<endl;
dcurrent->dk->showdisk();
break;
}
else
dcurrent=d
媒体库管理系统
最新推荐文章于 2024-05-15 20:34:05 发布