媒体库管理系统

这是一个实现媒体库管理的C++程序,包括添加、显示、查询、统计和删除图书、光盘和图画等媒体信息。程序通过链表管理数据,并使用文件输入输出流进行数据持久化。用户可以选择不同的操作,如按标题、编号或类别查询,查看统计信息等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

//这个是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
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值