媒体库管理系统即图书馆管理系统设计

时间:2020-11-28 17:55:27

媒体库管理系统即图书馆管理系统设计

                                                         《基于C++的面向对象程序设计实验报告》   

媒体库管理系统即图书馆管理系统设计


题目:图书馆管理系统设计

学院:

系别:计算机工程系

专业:计算机科学与技术

制作人:

学号:132054137

班级:1320541

 

 

2014年7月1号

 

目录

第一章:总体功能介绍

       1.1 问题描述................................................................................第3页

       1.2 功能介绍................................................................................第3页

        1.2.1  添加物品.......................................................................第3页

        1.2.2  显示物品库...................................................................第3页

        1.2.3  查询物品.......................................................................第3页

        1.2.4  编辑物品.......................................................................第3页

        1.2.5  删除物品.......................................................................第3页

        1.2.6  统计物品信息...............................................................第3页

        1.2.7  物品存盘........................................................................第4页

        1.2.8  读出物品........................................................................第4页

第二章:课程设计理念

       2.1 设计理念................................................................第4页

        2.2 设计过程...............................................................................第4页

        2.3 主菜单的实现.......................................................................第5页

        2.4 次菜单的实现.......................................................................第5页

第三章:各功能模块的实现及调试

        3.1  添加物品.............................................................................第6页

        3.2  显示物品库.........................................................................第6页

        3.3  查询物品.............................................................................第7页

        3.4  编辑物品.............................................................................第8页

        3.5  删除物品.............................................................................第9页

        3.6  统计物品信息.....................................................................第9页

第四章:调试过程中的问题

        4.1 程序中遇到过的问题..........................................................第10页

        4.2 问题的解决与编写后的感受.............................................第10页

第四章:总结............................................................................第11页

第五章:参考文献.....................................................................第11页

第七章:附源代码.....................................................................第11页

 

 

第一章:总体功能介绍

      1.1 问题介绍

    图书馆中的资料很多,如果能分类对其资料流通进行管理,将会带来很多方便,

因此需要有一个媒体库管理系统。图书馆共有三大类物品资料:图书、视频光盘、图画。这三类物品共同具有的属性有:编号、标题、作者、评级(未评级,一般,成人,儿童)等。其中图书类增加出版社、ISBN号、页数等信息;视频光盘类增加出品者的名字、出品年份和视频时长等信息;图画类增加出品国籍、作品的长和宽(以厘米计,整数)等信息。

        1.2 功能介绍

1.2.1  添加物品

添加物品:主要完成图书馆三类物品信息的添加,要求编号唯一。当添加了重复的编号时,则提示数据添加重复并取消添加;当物品库已满,则提示不能再添加新的数据。 

1.2.2  显示物品库.

显示物品库:输出当前物品库中所有物品信息,每条记录占据一行。

1.2.3  查询物品

    可按照2种方式来查询物品,分别为:

按标题查询:输入标题,输出所查询的信息,若不存在该记录,则提示“该标题不存在!”;

按编号查询:输入编号,输出所查询的信息,若不存在该记录,则提示“该编号不存在!”;

1.2.4  编辑物品

     编辑物品:可根据查询结果对相应的记录进行修改,修改时注意编号的唯一性。

1.2.5  删除物品

     删除物品:主要完成图书馆物品信息的删除。如果当前物品库为空,则提示“物品库为空!”,并返回操作;否则,输入要删除的编号,根据编号删除该物品的记录,如果该编号不在物品库中,则提示“该编号不存在”。

1.2.6  统计物品信息

    统计信息 

输出当前物品库中总物品数,以及按物品类别,统计出当前物品中各类别的物品数并显示。

 1.2.7  物品存盘

     将当前程序中的物品信息存入文件中。 

1.2.8  读出物品

     从文件中将物品信息读入程序。

第二章:课程设计理念

  2.1 设计理念:

箭头流程

 

箭头流程

媒体库管理系统即图书馆管理系统设计

 

2.2 设计过程

  主菜单:1.图画

          2.视频光盘

          3.图画

  次菜单:

          1.添加物品

          2.显示物品库

          3.查询物品

          4.编辑物品

          5 .删除物品

          6.统计物品

 

 

注:首先让客户在主菜单中选择(1.图画 2.视频光盘3.图画)中的一项,并进入次菜单中进行操作选择,而且客户还可以根据需求进行返回主菜单进行操作。

 

    2.3主菜单的实现:

 

        2.4次菜单的实现

 媒体库管理系统即图书馆管理系统设计

 

 

第三章:各功能模块的实现

3.1添加物品

3.2 显示物品

3.3  查询物品

媒体库管理系统即图书馆管理系统设计

         

      1.按标题查询

2.按编号查询

3.4  编辑物品(与之前相对比)

①  编辑后的信息:

 

② 编辑前的信息:

 媒体库管理系统即图书馆管理系统设计

 

 

 

 

3.5  删除物品

 

 

3.6  统计物品信息

 媒体库管理系统即图书馆管理系统设计

 

 

 

第五章:调试过程中的问题

 

       4.1 程序中遇到过的问题

 

面对如此比较复杂的问题,在设计过程中一定会遇到诸多的问题。

有程序逻辑方面上的逻辑错误,语法上的错误。

主要由以下几个方面:

 

① 标点符号出现错误,比较容易修改

 

② 结构体定义错误

 

③ 结构体的使用错误

 

④ 主函数的使用方法

 

⑤ 调用函数的使用方法

 

⑥ 非空函数的返回值

 

⑦ 主菜单的修改与美观

 

     4.2 问题的解决与感受

问题的解决:

 

1)       解决问题中,仔细查找错误

2)       多问同学与老师

3)       多交流问题

4)       上网查找资料

 

感受:

 

1.在编写程序过程中需谨慎

2.C++主要靠自己的动手能力

3.多参加一些软件开发,对自己的c++有很大的好处

4.虽然实验过程中出现诸多问题,但是解决后的心情是相当不错的

5.多试验多操作

6.多交流,多问

 

 

 

 

第五章:总结

    通过本次课程设计,对本学期C++课程习得的知识进行了一次综合运用,巩固了所学。而本次课程设计与现实联系比较紧密,综合性也比较强,锻炼了独立思考并解决问题的能力。课程设计分为两个阶段,对于处理问题比较有层次性,即逐步深入;而课程要求也对本次试验有一定的引导作用。完成了本次试验,对于其他编程项目,不论简单、复杂,也比较容易理解、接受、尝试、解决。 

         虽然,本次试验的完成比较顺利,但仍遇到许多的问题。需要多多练习,学好C++主要靠动手能力与逻辑思维能力。

     同时感谢韩老师的指导!!!

 

第六章:参考文献

     《C++程序设计》

第七章:附源代码

     媒体库管理系统.Cpp

#include<iostream>

#include<fstream>

#include<string>

#include<iomanip>

#include<cstdlib>//清屏头文件

using namespace std;

#define max 1000                           //最大容量

int num1=0,num2=0,num3=0;                  //物品数量

struct Book

{

                                                    

                                                     charid[20], title[20],author[20],grade[20],press[20],ISBN[20],page[10];

};

Book book[max];

 

void add1()                               //添加

{

                                                     ofstreamoutfile("book.txt",ios::binary);

                                                     if(!outfile)

                                                     {cerr<<"打开错误!"<<endl;

                                                     abort();

                                                     }

   char a;

                                                     if(num1>max)                      //如果当前数组的空间已满,提示用户不能再添加;

                                                     {

                                                        cout<<"空间已满,不能再添加了。"<<endl;

                                                        return;

                                                     }

                                                     else

                                                     {

                                                        for(int i=num1;i<=max;i++)

                                                        {

                                                               cout<<"请输入你要添加图书的编号:"<<endl;

                                                               cin>>book[i].id;

                                                               cout<<"请输入你要添加图书的标题:"<<endl;

                                                               cin>>book[i].title;

                                                               cout<<"请输入你要添加图书的作者:"<<endl;

                                                               cin>>book[i].author;

                                                               cout<<"请输入你要添加图书的评级(未评级、一般、成人、儿童):"<<endl;

                                                               cin>>book[i].grade;

                                                               cout<<"请输入你要添加图书的出版社:"<<endl;

                                                               cin>>book[i].press;

                                                               cout<<"请输入你要添加图书的ISBN:"<<endl;

                                                               cin>>book[i].ISBN;

                                                               cout<<"请输入你要添加图书的页数:"<<endl;

                                                               cin>>book[i].page;

                                                               num1++;

                                                               cout<<"你是否继续添加图书信息?是(y):否(n):"<<endl;

                                                               cin>>a;

                                                               if(a=='n'||a=='N')break;

                                                        }

                                                     }

                                                     for(inti=0;i<=num1;i++)

                                                     {outfile.write((char*)&book[i],sizeof(book[i]));

                                                     outfile.write((char*)&num1,sizeof(num1));

                                                     }

                                                    

                                                         outfile.close();

                                                         

}

void output1()                              //图书显示

{

                                                     ifstreaminfile1("book.txt",ios::binary);

                                                     if(!infile1)

                                                     {cerr<<"打开错误!"<<endl;

                                                     abort();

                                                     }

                                                     for(inti=0;i<=num1;i++)

                                                     {infile1.read((char*)&book[i],sizeof(book[i]));

                                                     infile1.read((char*)&num1,sizeof(num1));}

                                                     cout<<"        所有图书物品的信息如下:       "<<endl;

                                                     for(i=0;i<num1;i++)

                                                     {

                                                        cout<<"[[[*************************************]]]"<<endl;

                                                        cout<<"图书编号:";

                                                        cout<<book[i].id<<endl;

                                                        cout<<"图书标题:";

                                                        cout<<book[i].title<<endl;

                                                        cout<<"图书作者:";

                                                        cout<<book[i].author<<endl;

                                                        cout<<"图书评级(未评级、一般、成人、儿童): ";

                                                        cout<<book[i].grade<<endl;

                                                        cout<<"图书出版社: ";

                                                        cout<<book[i].press<<endl;

                                                        cout<<"图书ISBN:  ";

                                                        cout<<book[i].ISBN<<endl;

                                                        cout<<"图书页数: ";

                                                        cout<<book[i].page<<endl;

                                                       

                                                     }

                                                     infile1.close();

                                                    

}

void search1()                         //查找图书

{

                                                     ifstreaminfile1("book.txt",ios::binary);

                                                     if(!infile1)

                                                     {cerr<<"打开错误!"<<endl;

                                                     abort();

                                                     }

                                                     for(inti=0;i<=num1;i++)

                                                     {infile1.read((char*)&book[i],sizeof(book[i]));

                                                     infile1.read((char*)&num1,sizeof(num1));}

                                                    

                                                     charb;

                                                     stringc;

                                                     cout<<"请输入你要查询的图书的查询方式:(1或2)"<<endl;

                                                     cout<<"     1.按照标题查询          2.按照编号查询" <<endl;

                                                     cin>>b;

                                                     if(b=='1')

                                                     {

                                                        cout<<"请输入你要查询图书的标题:"<<endl;

                                                        cin>>c;

                                                        for( i=0;i<max;i++)

                                                        {

                                                               if(book[i].title==c)

                                                               {

                                                                      cout<<"你所要查的图书的所有信息如下:"<<endl;

                                                                      cout<<"[[[*************************************]]]"<<endl;

                                                                      cout<<"图书编号:";

                                                                      cout<<book[i].id<<endl;

                                                                      cout<<"图书标题:";

                                                                      cout<<book[i].title<<endl;

                                                                      cout<<"图书作者:";

                                                                      cout<<book[i].author<<endl;

                                                                      cout<<"图书评级(未评级、一般、成人、儿童): ";

                                                                      cout<<book[i].grade<<endl;

                                                                      cout<<"图书出版社: ";

                                                                      cout<<book[i].press<<endl;

                                                                      cout<<"图书ISBN:  ";

                                                                      cout<<book[i].ISBN<<endl;

                                                                      cout<<"图书页数: ";

                                                                      cout<<book[i].page<<endl;

                                                                      break;

                                                               }

                                                               if(i>num1)

                                                               {

                                                                      cout<<"该标题不存在!!!"<<endl;

                                                                      break;

                                                               }

                                                              

                                                        }

                                                       

                                                     }

                                                     else

                                                     {

                                                        cout<<"请输入你要查询图书的编号:"<<endl;

                                                        cin>>c;

                                                        for( i=0;i<max;i++)

                                                        {

                                                               if(book[i].id==c)

                                                               {

                                                                      cout<<"你所要查的图书的所有信息如下:"<<endl;

                                                                      cout<<"[[[*************************************]]]"<<endl;

                                                                      cout<<"图书编号:";

                                                                      cout<<book[i].id<<endl;

                                                                      cout<<"图书标题:";

                                                                      cout<<book[i].title<<endl;

                                                                      cout<<"图书作者:";

                                                                      cout<<book[i].author<<endl;

                                                                      cout<<"图书评级(未评级、一般、成人、儿童): ";

                                                                      cout<<book[i].grade<<endl;

                                                                      cout<<"图书出版社: ";

                                                                      cout<<book[i].press<<endl;

                                                                      cout<<"图书ISBN:  ";

                                                                      cout<<book[i].ISBN<<endl;

                                                                      cout<<"图书页数: ";

                                                                      cout<<book[i].page<<endl;

                                                                     

                                                                      break;

                                                               }

                                                               if(i>num1)

                                                               {

                                                                      cout<<"该编号不存在!!!"<<endl;

                                                                      break;

                                                               }

                                                              

                                                        }

                                                       

                                                     }

                                                     infile1.close();

}

void change1()                                        //图书修改

                                                     ifstreaminfile1("book.txt",ios::binary);

                                                     if(!infile1)

                                                     {cerr<<"打开错误!"<<endl;

                                                     abort();

                                                     }

                                                     for(int i=0;i<=num1;i++)

                                                     {infile1.read((char*)&book[i],sizeof(book[i]));

                                                     infile1.read((char*)&num1,sizeof(num1));}

                                                     ofstreamoutfile("book.txt",ios::binary);

                                                     if(!outfile)

                                                     {cerr<<"打开错误!"<<endl;

                                                     abort();

                                                     }

                                                     stringe;

                                                     cout<<"请输入你要修改数据的编号id:"<<endl;

                                                     cin>>e;

                                                     for(i=0;i<num1;i++)

                                                     {

                                                        if(book[i].id==e)

                                                        {

                                                               cout<<"[请输入你要修改该图书的所有信息:]"<<endl;

                                                               cout<<"图书标题:"<<endl;

                                                               cin>>book[i].title;

                                                               cout<<"图书作者:";

                                                               cin>>book[i].author;

                                                               cout<<"图书评级(未评级、一般、成人、儿童): ";

                                                               cin>>book[i].grade;

                                                               cout<<"图书出版社: ";

                                                               cin>>book[i].press;

                                                               cout<<"图书ISBN:  ";

                                                               cin>>book[i].ISBN;

                                                               cout<<"图书页数: ";

                                                               cin>>book[i].page;

                                                        }

                                                     }

                                                     for(i=0;i<=num1;i++)

                                                     {outfile.write((char*)&book[i],sizeof(book[i]));

                                                     }

                                                     infile1.close();

                                                     outfile.close();

                                                    

}

void delete1()                                     //图书删除

{

                                                     ifstreaminfile1("book.txt",ios::binary);

                                                     if(!infile1)

                                                     {cerr<<"打开错误!"<<endl;

                                                     abort();

                                                     }

                                                     for(inti=0;i<=num1;i++)

                                                     {infile1.read((char*)&book[i],sizeof(book[i]));

                                                     infile1.read((char*)&num1,sizeof(num1));}

                                                     ofstreamoutfile("book.txt",ios::binary);

                                                     if(!outfile)

                                                     {cerr<<"打开错误!"<<endl;

                                                     abort();

                                                     }

                                                     stringe;

                                                     intj;

                                                     if(num1==0)

                                                        cout<<"该物品库为空!!!"<<endl;

                                                     else

                                                     {

                                                        cout<<"请输入你要删除数据的编号id:"<<endl;

                                                        cin>>e;

                                                        for( i=0;i<max;i++)

                                                        {

                                                               if(book[i].id==e)

                                                               {

                                                                     

                                                                      for( j=i+1;j<=num1-1;j++)

                                                                            

                                                                      {strcpy(book[j-1].id,book[j].id);

                                                                      strcpy(book[j-1].title,book[j].title);

                                                                      strcpy(book[j-1].author,book[j].author);

                                                                      strcpy(book[j-1].grade,book[j].grade);

                                                                      strcpy(book[j-1].press,book[j].press);

                                                                      strcpy(book[j-1].ISBN,book[j].ISBN);

                                                                      strcpy(book[j-1].page,book[j].page);

                                                                      }

                                                                      num1--;

                                                                      break;

                                                               }

                                                        }

                                                        if(i>num1)

                                                               cout<<"该标题不存在!!!"<<endl;

                                                        else

                                                               cout<<"删除成功!!!"<<endl;

                                                       

                                                        for(i=0;i<=num1;i++)

                                                        {outfile.write((char*)&book[i],sizeof(book[i]));

                                                        outfile.write((char*)&num1,sizeof(num1));

                                                        }

                                                        infile1.close();

                                                        outfile.close();

                                                     }

                                                    

                                                    

}

struct Video                                             //视频结构体

{

                                                     charid[20],title[20],author[20],grade[20],year[20],time[20];

};

Video video[max];

void add2()                                             //视频添加

{

                                                     ofstreamoutfile("video.txt",ios::binary);

                                                     if(!outfile)

                                                     {cerr<<"打开错误!"<<endl;

                                                     abort();

                                                     }

                                                     chara;

                                                     if(num2>max)                                        //如果当前数组的空间已满,提示用户不能再添加;

                                                     {

                                                        cout<<"空间已满,不能再添加了。"<<endl;

                                                        return;

                                                     }

                                                     else

                                                     {

                                                        for(int i=num2;i<=max;i++)

                                                        {

                                                               cout<<"请输入你要增加视屏光盘的编号:"<<endl;

                                                               cin>>video[i].id;

                                                               cout<<"请输入你要增加视屏光盘的标题:"<<endl;

                                                               cin>>video[i].title;

                                                               cout<<"请输入你要增加视屏光盘的作者:"<<endl;

                                                               cin>>video[i].author;

                                                               cout<<"请输入你要增加视屏光盘的评级(未评级、一般、成人、儿童):"<<endl;

                                                               cin>>video[i].grade;

                                                               cout<<"请输入你要增加视屏光盘的出版年份:"<<endl;

                                                               cin>>video[i].year;

                                                               cout<<"请输入你要增加视屏光盘的时长:"<<endl;

                                                               cin>>video[i].time;

                                                               num2++;

                                                               cout<<"你是否继续增加视屏光盘信息?是(y):否(n):"<<endl;

                                                               cin>>a;

                                                               if(a=='n'||a=='N')break;

                                                        }

                                                     }

                                                     for(int i=0;i<=num2;i++)

                                                     {outfile.write((char*)&video[i],sizeof(video[i]));

                                                     outfile.write((char*)&num2,sizeof(num2));

                                                     }

                                                     outfile.close();

}

void output2()                                           //视频显示

{

                                                     ifstreaminfile2("video.txt",ios::binary);

                                                     if(!infile2)

                                                     {cerr<<"打开错误!"<<endl;

                                                     abort();

                                                     }

                                                     for(inti=0;i<=num2;i++)

                                                     {infile2.read((char*)&video[i],sizeof(video[i]));

                                                     infile2.read((char*)&num2,sizeof(num2));}

                                                     infile2.close();

                                                     cout<<"        所有视频光盘物品的信息如下:       "<<endl;

                                                     for(i=0;i<num2;i++)

                                                     {

                                                        cout<<"[[[*************************************]]]"<<endl;

                                                        cout<<"视屏光盘编号:";

                                                        cout<<video[i].id<<endl;

                                                        cout<<"视屏光盘标题:";

                                                        cout<<video[i].title<<endl;

                                                        cout<<"视屏光盘作者:";

                                                        cout<<video[i].author<<endl;

                                                        cout<<"视屏光盘评级(未评级、一般、成人、儿童): ";

                                                        cout<<video[i].grade<<endl;

                                                        cout<<"视屏光盘的出版年份: ";

                                                        cout<<video[i].year<<endl;

                                                        cout<<"视屏光盘的时长: ";

                                                        cout<<video[i].time<<endl;

                                                       

                                                     }

}

void search2()                                           //查找视频

{                                                    ifstreaminfile2("video.txt",ios::binary);

if(!infile2)

{cerr<<"打开错误!"<<endl;

abort();

}

for(int i=0;i<=num2;i++)

{infile2.read((char*)&video[i],sizeof(video[i]));

infile2.read((char*)&num2,sizeof(num2));}

char b;

string c;

cout<<"请输入你要查询的视频光盘的查询方式:(1或2)"<<endl;

cout<<"     1.按照标题查询          2.按照编号查询" <<endl;

cin>>b;

if(b=='1')

{

                                                     cout<<"请输入你要查询视频光盘的标题:"<<endl;

                                                     cin>>c;

                                                     for(i=0;i<max;i++)

                                                     {

                                                        if(video[i].title==c)

                                                        {     cout<<"你所要查的视频光盘的所有信息如下:"<<endl;

                                                        cout<<"[[[*************************************]]]"<<endl;

                                                        cout<<"视屏光盘编号:";

                                                        cout<<video[i].id<<endl;

                                                        cout<<"视屏光盘标题:";

                                                        cout<<video[i].title<<endl;

                                                        cout<<"视屏光盘作者:";

                                                        cout<<video[i].author<<endl;

                                                        cout<<"视屏光盘评级(未评级、一般、成人、儿童): ";

                                                        cout<<video[i].grade<<endl;

                                                        cout<<"视屏光盘的出版年份: ";

                                                        cout<<video[i].year<<endl;

                                                        cout<<"视屏光盘的时长: ";

                                                        cout<<video[i].time<<endl;

                                                        break;

                                                        }

                                                        if(i>num2)

                                                        {

                                                               cout<<"该视频光盘标题不存在!!!"<<endl;

                                                               break;

                                                        }

                                                       

                                                     }

}

else

{

                                                     cout<<"请输入你要查询视频光盘的编号:"<<endl;

                                                     cin>>c;

                                                     for(i=0;i<max;i++)

                                                     {

                                                       

                                                        if(video[i].id==c)

                                                        {

                                                               cout<<"你所要查的视频光盘的所有信息如下:"<<endl;

                                                               cout<<"[[[*************************************]]]"<<endl;

                                                               cout<<"视屏光盘编号:";

                                                               cout<<video[i].id<<endl;

                                                               cout<<"视屏光盘标题:";

                                                               cout<<video[i].title<<endl;

                                                               cout<<"视屏光盘作者:";

                                                               cout<<video[i].author<<endl;

                                                               cout<<"视屏光盘评级(未评级、一般、成人、儿童): ";

                                                               cout<<video[i].grade<<endl;

                                                               cout<<"视屏光盘的出版年份: ";

                                                               cout<<video[i].year<<endl;

                                                               cout<<"视屏光盘的时长: ";

                                                               cout<<video[i].time<<endl;

                                                               break;

                                                        }

                                                        if(i>num2)

                                                        {

                                                               cout<<"该视频光盘编号不存在!!!"<<endl;

                                                               break;

                                                        }

                                                       

                                                     }

                                                    

}

infile2.close();

}

void change2()                                            //视频编辑

{  ifstream infile2("video.txt",ios::binary);

if(!infile2)

{cerr<<"打开错误!"<<endl;

abort();

}

for(int i=0;i<=num2;i++)

{infile2.read((char*)&video[i],sizeof(video[i]));

infile2.read((char*)&num2,sizeof(num2));}

ofstreamoutfile("video.txt",ios::binary);

if(!outfile)

{cerr<<"打开错误!"<<endl;

abort();

}

string e;

cout<<"请输入你要修改数据的编号id:"<<endl;

cin>>e;

for( i=0;i<num2;i++)

{

                                                     if(video[i].id==e)

                                                     {

                                                        cout<<"[请输入你要修改该视频光盘的所有信息:]"<<endl;

                                                        cout<<"视频光盘标题:"<<endl;

                                                        cin>>video[i].title;

                                                        cout<<"视频光盘作者:";

                                                        cin>>video[i].author;

                                                        cout<<"视频光盘评级(未评级、一般、成人、儿童): ";

                                                        cin>>video[i].grade;

                                                        cout<<"视频光盘出版年份:  ";

                                                        cin>>video[i].year;

                                                        cout<<"视频光盘时长: ";

                                                        cin>>video[i].time;

                                                     }

}

for(i=0;i<=num2;i++)

{outfile.write((char*)&video[i],sizeof(video[i]));

outfile.write((char*)&num2,sizeof(num2));

}

infile2.close();

outfile.close();

}

void delete2()                                     //图书删除

{

                                                     ifstreaminfile2("video.txt",ios::binary);

                                                     if(!infile2)

                                                     {cerr<<"打开错误!"<<endl;

                                                     abort();

                                                     }

                                                     for(inti=0;i<=num2;i++)

                                                     {infile2.read((char*)&video[i],sizeof(video[i]));

                                                     infile2.read((char*)&num2,sizeof(num2));}

                                                     ofstreamoutfile("video.txt",ios::binary);

                                                     if(!outfile)

                                                     {cerr<<"打开错误!"<<endl;

                                                     abort();

                                                     }

                                                     stringe;

                                                     intj;

                                                     if(num2==0)

                                                        cout<<"该物品库为空!!!"<<endl;

                                                     else

                                                     {

                                                        cout<<"请输入你要删除数据的编号id:"<<endl;

                                                        cin>>e;

                                                        for( i=0;i<max;i++)

                                                        {

                                                               if(video[i].id==e)

                                                               {    

                                                                      for( j=i+1;j<=num2-1;j++)

                                                                            

                                                                      {strcpy(video[j-1].id,video[j].id);

                                                                      strcpy(video[j-1].title,video[j].title);

                                                                      strcpy(video[j-1].author,video[j].author);

                                                                      strcpy(video[j-1].grade,video[j].grade);

                                                                      strcpy(video[j-1].year,video[j].year);

                                                                      strcpy(video[j-1].time,video[j].time);

                                                                      }

                                                                      num2--;

                                                                      break;

                                                               }

                                                        }

                                                        if(i>num2)

                                                               cout<<"该标题不存在!!!"<<endl;

                                                        else

                                                               cout<<"删除成功!!!"<<endl;

                                                     }

                                                     for(i=0;i<=num2;i++)

                                                     {outfile.write((char*)&video[i],sizeof(video[i]));

                                                     outfile.write((char*)&num2,sizeof(num2));

                                                     }

                                                     infile2.close();

                                                     outfile.close();  

}

struct Picture

{

                                                     charid[20],title[20],author[20],grade[20],nation[20],longth[20],width[20];

};

Picture picture[max];

void add3()                                              //图画添加

{

                                                     ofstreamoutfile("picture.txt",ios::binary);

                                                     if(!outfile)

                                                     {cerr<<"打开错误!"<<endl;

                                                     abort();

                                                     }

                                                     chara;

                                                     if(num3>max)                                     //如果当前数组的空间已满,提示用户不能再添加;

                                                     {

                                                        cout<<"空间已满,不能再添加了。"<<endl;

                                                        return;

                                                     }

                                                     else

                                                     {

                                                        for(int i=num3;i<=max;i++)

                                                        {

                                                               cout<<"请输入你要添加图画的编号:"<<endl;

                                                               cin>>picture[i].id;

                                                               cout<<"请输入你要添加图画的标题:"<<endl;

                                                               cin>>picture[i].title;

                                                               cout<<"请输入你要添加图画的作者:"<<endl;

                                                               cin>>picture[i].author;

                                                               cout<<"请输入你要添加图画的评级(未评级、一般、成人、儿童):"<<endl;

                                                               cin>>picture[i].grade;

                                                               cout<<"请输入你要添加图画的出品国籍:"<<endl;

                                                               cin>>picture[i].nation;

                                                               cout<<"请输入你要添加图画的长度(单位cm整数):"<<endl;

                                                               cin>>picture[i].longth;

                                                               cout<<"请输入你要添加图画的宽度(单位cm整数):"<<endl;

                                                               cin>>picture[i].width;

                                                               num3++;

                                                               cout<<"你是否继续添加图画信息?是(y):否(n):"<<endl;

                                                               cin>>a;

                                                               if(a=='n'||a=='N')break;

                                                              

                                                        }

                                                     }

                                                     for(inti=0;i<=num3;i++)

                                                     {outfile.write((char*)&picture[i],sizeof(picture[i]));

                                                     outfile.write((char*)&num3,sizeof(num3));

                                                     }

                                                     outfile.close();

                                                    

}

void output3()                                             //图画删除

{

                                                     ifstreaminfile3("picture.txt",ios::binary);

                                                     if(!infile3)

                                                     {cerr<<"打开错误!"<<endl;

                                                     abort();

                                                     }

                                                     for(inti=0;i<=num3;i++)

                                                     {infile3.read((char*)&picture[i],sizeof(picture[i]));

                                                     infile3.read((char*)&num3,sizeof(num3));}

                                                     cout<<"        所有图画物品的信息如下:       "<<endl;

                                                     for(i=0;i<num3;i++)

                                                     {

                                                        cout<<"[[[*************************************]]]"<<endl;

                                                        cout<<"图画编号:";

                                                        cout<<picture[i].id<<endl;

                                                        cout<<"图画标题:";

                                                        cout<<picture[i].title<<endl;

                                                        cout<<"图画作者:";

                                                        cout<<picture[i].author<<endl;

                                                        cout<<"图画评级(未评级、一般、成人、儿童): ";

                                                        cout<<picture[i].grade<<endl;

                                                        cout<<"图画出品国籍: ";

                                                        cout<<picture[i].nation<<endl;

                                                        cout<<"图画的长度(单位cm整数):   ";

                                                        cout<<picture[i].longth<<endl;

                                                        cout<<"图画的宽度(单位cm整数):  ";

                                                        cout<<picture[i].width<<endl;

                                                       

                                                     }

                                                     infile3.close();

}

 

void search3()                                              //查找图画

{

                                                     ifstreaminfile3("picture.txt",ios::binary);

                                                     if(!infile3)

                                                     {cerr<<"打开错误!"<<endl;

                                                     abort();

                                                     }

                                                     for(inti=0;i<=num3;i++)

                                                     {infile3.read((char*)&picture[i],sizeof(picture[i]));

                                                     infile3.read((char*)&num3,sizeof(num3));}

                                                     charb;

                                                     stringc;

                                                     cout<<"请输入你要查询的图画的查询方式:(1或2)"<<endl;

                                                     cout<<"     1.按照标题查询          2.按照编号查询" <<endl;

                                                     cin>>b;

                                                     if(b=='1')

                                                     {

                                                        cout<<"请输入你要查询图画的标题:"<<endl;

                                                        cin>>c;

                                                        for( i=0;i<max;i++)

                                                        {

                                                               if(picture[i].title==c)

                                                               {

                                                                      cout<<"你所要查的图画的所有信息如下:"<<endl;

                                                                      cout<<"[[[*************************************]]]"<<endl;

                                                                      cout<<"图画编号:";

                                                                      cout<<picture[i].id<<endl;

                                                                      cout<<"图画标题:";

                                                                      cout<<picture[i].title<<endl;

                                                                      cout<<"图画作者:";

                                                                      cout<<picture[i].author<<endl;

                                                                      cout<<"图画评级(未评级、一般、成人、儿童): ";

                                                                      cout<<picture[i].grade<<endl;

                                                                      cout<<"图画出品国籍: ";

                                                                      cout<<picture[i].nation<<endl;

                                                                      cout<<"图画的长度(单位cm整数):   ";

                                                                      cout<<picture[i].longth<<endl;

                                                                      cout<<"图画的宽度(单位cm整数):  ";

                                                                      cout<<picture[i].width<<endl;

                                                                      break;

                                                               }

                                                               if(i>num3)

                                                               {

                                                                      cout<<"该标题不存在!!!"<<endl;

                                                                      break;

                                                               }

                                                              

                                                        }

                                                       

                                                     }

                                                     else

                                                     {

                                                        cout<<"请输入你要查询图画的编号:"<<endl;

                                                        cin>>c;

                                                        for( i=0;i<max;i++)

                                                        {

                                                              

                                                               if(picture[i].id==c)

                                                               {

                                                                      cout<<"你所要查的图画的所有信息如下:"<<endl;

                                                                      cout<<"[[[*************************************]]]"<<endl;

                                                                      cout<<"图画编号:";

                                                                      cout<<picture[i].id<<endl;

                                                                      cout<<"图画标题:";

                                                                      cout<<picture[i].title<<endl;

                                                                      cout<<"图画作者:";

                                                                      cout<<picture[i].author<<endl;

                                                                      cout<<"图画评级(未评级、一般、成人、儿童): ";

                                                                      cout<<picture[i].grade<<endl;

                                                                      cout<<"图画出品国籍: ";

                                                                      cout<<picture[i].nation<<endl;

                                                                      cout<<"图画的长度(单位cm整数):   ";

                                                                      cout<<picture[i].longth<<endl;

                                                                      cout<<"图画的宽度(单位cm整数):  ";

                                                                      cout<<picture[i].width<<endl;

                                                                      break;

                                                               }

                                                               if(i>num3)

                                                               {

                                                                      cout<<"该编号不存在!!!"<<endl;

                                                                      break;

                                                               }

                                                              

                                                              

                                                        }

                                                       

                                                     }

                                                     infile3.close();

}

void change3()                                           //图画修改

{  

                                                     ifstreaminfile3("picture.txt",ios::binary);

                                                     if(!infile3)

                                                     {cerr<<"打开错误!"<<endl;

                                                     abort();

                                                     }

                                                     for(inti=0;i<=num3;i++)

                                                     {infile3.read((char*)&picture[i],sizeof(picture[i]));

                                                     infile3.read((char*)&num3,sizeof(num3));}

                                                     ofstreamoutfile("picture.txt",ios::binary);

                                                     if(!outfile)

                                                     {cerr<<"打开错误!"<<endl;

                                                     abort();

                                                     }

                                                     stringe;

                                                     cout<<"请输入你要修改数据的编号id:"<<endl;

                                                     cin>>e;

                                                     for(i=0;i<num3;i++)

                                                     {

                                                        if(picture[i].id==e)

                                                        {

                                                               cout<<"[请输入你要修改该图画的所有信息:]"<<endl;

                                                               cout<<"请输入你要修改图画的标题:"<<endl;

                                                               cin>>picture[i].title;

                                                               cout<<"请输入你要修改图画的作者:"<<endl;

                                                               cin>>picture[i].author;

                                                               cout<<"请输入你要修改图画的评级(未评级、一般、成人、儿童):"<<endl;

                                                               cin>>picture[i].grade;

                                                               cout<<"请输入你要修改图画的出品国籍:"<<endl;

                                                               cin>>picture[i].nation;

                                                               cout<<"请输入你要修改图画的长度(单位cm整数):"<<endl;

                                                               cin>>picture[i].longth;

                                                               cout<<"请输入你要修改图画的宽度(单位cm整数):"<<endl;

                                                               cin>>picture[i].width;

                                                              

                                                        }

                                                     }

                                                     for(i=0;i<=num3;i++)

                                                     {outfile.write((char*)&picture[i],sizeof(picture[i]));

                                                     outfile.write((char*)&num3,sizeof(num3));

                                                     }

                                                     infile3.close();

                                                     outfile.close();

                                                    

                                                    

}

void delete3()                                           //图画删除

{

                                                     ifstreaminfile3("picture.txt",ios::binary);

                                                     if(!infile3)

                                                     {cerr<<"打开错误!"<<endl;

                                                     abort();

                                                     }

                                                     for(inti=0;i<=num3;i++)

                                                     {infile3.read((char*)&picture[i],sizeof(picture[i]));

                                                     infile3.read((char*)&num3,sizeof(num3));}

                                                     ofstreamoutfile("picture.txt",ios::binary);

                                                     if(!outfile)

                                                     {cerr<<"打开错误!"<<endl;

                                                     abort();

                                                     }

                                                     stringe;

                                                     intj;

                                                     if(num3==0)

                                                        cout<<"该物品库为空!!!"<<endl;

                                                     else

                                                     {

                                                        cout<<"请输入你要删除数据的编号id:"<<endl;

                                                        cin>>e;

                                                        for( i=0;i<max;i++)

                                                        {

                                                               if(picture[i].id==e)

                                                               {    

                                                                      for( j=i+1;j<=num3-1;j++)

                                                                            

                                                                      {strcpy(picture[j-1].id,picture[j].id);

                                                                      strcpy(picture[j-1].title,picture[j].title);

                                                                      strcpy(picture[j-1].author,picture[j].author);

                                                                      strcpy(picture[j-1].grade,picture[j].grade);

                                                                      strcpy(picture[j-1].nation,picture[j].nation);

                                                                      strcpy(picture[j-1].longth,picture[j].longth);

                                                                      strcpy(picture[j-1].width,picture[j].width);

                                                                      }

                                                                      num3--;

                                                                      break;

                                                               }

                                                        }

                                                        if(i>num3)

                                                               cout<<"该标题不存在!!!"<<endl;

                                                        else

                                                               cout<<"删除成功!!!"<<endl;

                                                     }

                                                     for(i=0;i<=num3;i++)

                                                     {outfile.write((char*)&picture[i],sizeof(picture[i]));

                                                     outfile.write((char*)&num3,sizeof(num3));

                                                     }

                                                     infile3.close();

                                                     outfile.close();

}

void count()                                    //统计总物品信息

 

{         //图书的个数信息查询

                                                     ifstreaminfile1("book.txt",ios::binary);

                                                     if(!infile1)

                                                     {cerr<<"打开错误!"<<endl;

                                                     abort();

                                                     }

                                                     for(int i=0;i<=num1;i++)

                                                     {infile1.read((char*)&book[i],sizeof(book[i]));

                                                     infile1.read((char*)&num1,sizeof(num1));}

                                                     //视频光盘的个数信息查询

                                                     ifstreaminfile2("video.txt",ios::binary);

                                                     if(!infile2)

                                                     {cerr<<"打开错误!"<<endl;

                                                     abort();

                                                     }

                                                     for(i=0;i<=num2;i++)

                                                     {infile2.read((char*)&video[i],sizeof(video[i]));

                                                     infile2.read((char*)&num2,sizeof(num2));}

                                                     //图画的个数信息查询

                                                     ifstreaminfile3("picture.txt",ios::binary);

                                                     if(!infile3)

                                                     {cerr<<"打开错误!"<<endl;

                                                     abort();

                                                     }

                                                     for(i=0;i<=num3;i++)

                                                     {infile3.read((char*)&picture[i],sizeof(picture[i]));

                                                     infile3.read((char*)&num3,sizeof(num3));}

   cout<<"               统计总物品信息(数量个数:)            "<<endl;

                                                     cout<<"           图书共有:       ";

                                                     cout<<num1<<"本"<<endl;

   cout<<"           视频光盘共有:  ";

                                                     cout<<num2<<"碟"<<endl;

                                                     cout<<"           图画共有:       ";

                                                     cout<<num3<<"本"<<endl;

                                                     infile1.close();

                                                     infile2.close();

                                                     infile3.close();

}

 

int main()                                           //主函数

{

                                                     charf;

                                                     system("color1b");

                                                     while(1)

                                                     {

                                                        cout<<"*************欢迎进入媒体库管理系统***************"<<endl;

                                                        cout<<"*该简易系统的制作人:刘创  制作日期:2014年6月25日*"<<endl;

                                                        cout<<"********///////////////主菜单///////////**********"<<endl;

                                                        cout<<"*///////              1.图书            /////////* "<<endl;

                                                        cout<<"*///////              2.视频光盘        /////////* "<<endl;

                                                        cout<<"*///////              3.图画            /////////* "<<endl;

                                                        cout<<"****///////////请输入您的选择(1~3)////////********"<<endl;

                                                        char ch,g,k;

                                                        cin>>g;

                                                        switch(g)

                                                              

                                                        {

                                                              

                                                        case'1':while(1)

                                                                      {     system("cls");

                                                                              cout<<"***************************************************************************"<<endl;

                                                               cout<<"                     ……欢迎进入图书类……                               "<<endl;

                                                               cout<<"***1.添加物品     2.显示物品     3.查询物品     4.编辑物品             ***"<<endl;

                                                               cout<<"***5.删除物品     6.统计物品     7.安全退出该系统                     ***"<<endl;

                                                               cout<<"***                    请输入你要的操作(1-7):                        ***"<<endl;

                                                                              cout<<"***************************************************************************"<<endl;

                                                               cin>>ch;

                                                               {

                                                                      switch(ch)

                                                                      {

                                                                            

                                                                      case'1': add1();break;

                                                                      case '2': output1();break;

                                                                      case '3': search1();break;

                                                                      case '4': change1();break;

                                                                      case '5': delete1();break;

                                                                      case '6': count();break;

                                                                      case '7':cout<<"已安全退出该系统!"<<endl;break;

                                                                      default:cout<<"没有此操作选项"<<endl;break;

                                                                      }

                                                                     

                                                               }cout<<"请问您是否还需要在此图书中继续操作?(y:是;n:否)";

                                                               cin>>k;if(k=='n'||k=='N')break;

                                                                      }

                                                              

                                                               break;

                                                              

                                                        case'2':

                                                               while(1)

                                                               {     system("cls");

                                                                            cout<<"****************************************************************************"<<endl;

                                                               cout<<"                   ……欢迎进入视频光盘类……                             "<<endl;

                                                               cout<<"***1.添加物品     2.显示物品     3.查询物品     4.编辑物品             ***"<<endl;

                                                               cout<<"***5.删除物品     6.统计物品     7.安全退出该系统                     ***"<<endl;

                                                               cout<<"***                    请输入你要的操作(1-7):                        ***"<<endl;

                                                                              cout<<"***************************************************************************"<<endl;

                                                               cin>>ch;

                                                               {

                                                                      switch(ch)

                                                                      {

                                                                            

                                                                      case '1': add2();break;

                                                                      case '2': output2();break;

                                                                      case '3': search2();break;

                                                                      case '4': change2();break;

                                                                      case '5': delete2();break;

                                                                      case '6': count();break;

                                                                      case '7':cout<<"已安全退出该系统!"<<endl;break;

                                                                      default:cout<<"没有此操作选项"<<endl;break;

                                                                      }

                                                                     

                                                               }cout<<"请问您是否还需要在此视频光盘中继续操作?(y:是;n:否)";

                                                               cin>>k;if(k=='n'||k=='N')break;

                                                               }

                                                               break;

                                                        case'3':

                                                               while(1)

                                                               {     system("cls");

                                                                              cout<<"***************************************************************************"<<endl;

                                                               cout<<"                     ……欢迎进入图画类……                               "<<endl;

                                                               cout<<"***1.添加物品     2.显示物品     3.查询物品     4.编辑物品             ***"<<endl;

                                                               cout<<"***5.删除物品     6.统计物品     7.安全退出该系统                     ***"<<endl;

                                                               cout<<"***                    请输入你要的操作(1-7):                        ***"<<endl;

                                                                              cout<<"***************************************************************************"<<endl;

                                                               cin>>ch;

                                                               {

                                                                      switch(ch)

                                                                      {

                                                                            

                                                                      case'1': add3();break;

                                                                      case '2': output3();break;

                                                                      case '3': search3();break;

                                                                      case '4': change3();break;

                                                                      case '5': delete3();break;

                                                                      case '6': count();break;

                                                                      case '7':cout<<"已安全退出该系统!"<<endl;break;

                                                                      default:cout<<"没有此操作选项"<<endl;break;

                                                                      }

                                                                     

                                                               }cout<<"请问您你是否还需要在此图画中继续操作?(y:是;n:否)";

                                                              

                                                               cin>>k;if(k=='n'||k=='N')break;

                                                               }

                                                               break;

                                                        default:cout<<"没有此操作选项"<<endl;break;

                                                              

                                                        }

                                                        system("cls");

                                                        cout<<"请问您是否需要返回主菜单中继续操作?(y:是;n:否)";

                                                        cin>>f;

                                                        if(f=='n'||f=='N')break;

                                                     }

                                                    

                                                     return0;

}