C++面向对象程序设计媒体库管理系统设计.docx

上传人:b****6 文档编号:5986978 上传时间:2023-01-02 格式:DOCX 页数:32 大小:104.33KB
下载 相关 举报
C++面向对象程序设计媒体库管理系统设计.docx_第1页
第1页 / 共32页
C++面向对象程序设计媒体库管理系统设计.docx_第2页
第2页 / 共32页
C++面向对象程序设计媒体库管理系统设计.docx_第3页
第3页 / 共32页
C++面向对象程序设计媒体库管理系统设计.docx_第4页
第4页 / 共32页
C++面向对象程序设计媒体库管理系统设计.docx_第5页
第5页 / 共32页
点击查看更多>>
下载资源
资源描述

C++面向对象程序设计媒体库管理系统设计.docx

《C++面向对象程序设计媒体库管理系统设计.docx》由会员分享,可在线阅读,更多相关《C++面向对象程序设计媒体库管理系统设计.docx(32页珍藏版)》请在冰豆网上搜索。

C++面向对象程序设计媒体库管理系统设计.docx

C++面向对象程序设计媒体库管理系统设计

(一)、课程设计题目:

媒体库管理系统

(二)、目的与要求:

1、目的:

(1)要求学生达到熟练掌握C++语言的基本知识和技能;

(2)基本掌握面向对象程序设计的基本思路和方法;

(3)能够利用所学的基本知识和技能,解决简单的面向对象程序设计问题。

2、基本要求:

(1)要求利用面向对象的方法以及C++的编程思想来完成系统的设计;

(2)要求在设计的过程中,建立清晰的类层次;

(3)在系统中至少要定义四个类,每个类中要有各自的属性和方法;

(4)在系统的设计中,至少要用到面向对象的一种机制。

3、创新要求:

在基本要求达到后,可进行创新设计,如根据查找结果进行修改的功能。

(三)、设计方法和基本原理:

功能要求:

1)添加物品

程序主要完成图书馆三类物品信息的添加,要求编号唯一。

如果添加了重复编号的物品时,则提示用户数据添加重复并取消添加;如果物品库已满,则提示不能再添加新的物品。

2)查询物品

可按照三种方式进行物品的查询。

·按标题查询:

·按编号查询:

·按类别查询:

如果未找到,给出相应的提示信息,如果找到,则显示相应的记录信息。

3)显示物品库

可显示当前物品库中所有的物品信息。

4)修改物品

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

5)删除物品

对已添加的物品信息进行删除。

如果当前物品库为空,则提示“物品库为空!

”并返回操作;否则输入要删除的编号,根据编号删除该物品信息,如果没有找到该物品信息,则提示“该编号不存在”。

6)统计功能

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

7)保存物品

将当前系统中物品信息存入文件中。

8)读取物品

将保存在文件中的物品信息读入到当前系统中,以供用户使用。

在完成以上基本功能的基础上,可自行进行扩展或完善。

1.系统需求分析

1.1系统设计的目的与意义:

图书馆中的资料很多,如果能分类对其资料流通进行管理,将会带来很多方便,因此需要有一个媒体库管理系统。

1.2系统功能需求:

图书馆共有三大类物品资料:

图书、视频光盘、图画。

1)添加物品

程序主要完成图书馆三类物品信息的添加,要求编号唯一。

如果添加了重复编号的物品时,则提示用户数据添加重复并取消添加;如果物品库已满,则提示不能再添加新的物品。

2)查询物品

可按照三种方式进行物品的查询。

·按标题查询:

·按编号查询:

·按类别查询:

如果未找到,给出相应的提示信息,如果找到,则显示相应的记录信息。

3)显示物品库

可显示当前物品库中所有的物品信息。

4)修改物品

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

5)删除物品

对已添加的物品信息进行删除。

如果当前物品库为空,则提示“物品库为空!

”并返回操作;否则输入要删除的编号,根据编号删除该物品信息,如果没有找到该物品信息,则提示“该编号不存在”。

6)统计功能

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

7)保存物品

将当前系统中物品信息存入文件中。

8)读取物品

将保存在文件中的物品信息读入到当前系统中,以供用户使用。

在完成以上基本功能的基础上,可自行进行扩展或完善。

2.总体设计

2.1系统功能分析:

系统通过调用函数来实现信息录入、信息修改、信息删除、信息查询以及数据保存文件等功能。

add()函数用于录入信息;modify()函数用来修改信息;del()函数用来修改信息;searchStu()及searchScore()函数用来查询某班级中所有学生信息及查询某学生所有课程的成绩信息;read()函数用于将文件中的数据读取到内存中;save()函数用于将内存中的信息存入文件内;主函数main()用于调用这些函数。

2.2系统功能模块划分与设计:

系统定义了Class类、Student类、Course类、Score类这四个类,定义了add()、modify()、del()、read()及save()等函数来实现系统所需功能。

2.3系统功能模块图:

2.4类的设计

(1)Base类(抽象类)的设计:

 

 

图3.1Base类

(2)图书类的设计:

图3.2图书类

(3)视频类的设计:

图3.3视频类

(4)图画类的设计:

图3.4图画类

3.详细设计及实现

3.1Base类(抽象类)的实现

classBase

{

public:

charnumber[20];//编号

chartitle[11];//标题

charwriter[8];//作者

chargrade[20];//评级

virtualvoidread()=0;

virtualvoidadd()=0;

virtualvoidmodify(int)=0;

virtualvoiddel(int)=0;

virtualvoidsave()=0;

};

3.2图书类的实现

Book.h

classBook:

publicBase

{

public:

charnumber[20];//编号

chartitle[11];//标题

charwriter[8];//作者

chargrade[20];//评级

intISBNno;//ISBN号

charpress[9];//出版社

intpage;//页数

voidread();

voidadd();

voidmodify(int);

voiddel(int);

voidsave();

};

Book.cpp

voidBook:

:

read()

{

fstreambookfile("图书类信息.dat",ios:

:

in|ios:

:

out);

bookfile>>b1[count_Book].number>>b1[count_Book].title>>b1[count_Book].writer>>b1[count_Book].grade>>b1[count_Book].ISBNno>>b1[count_Book].press>>b1[count_Book].page;

while(!

bookfile.eof())

{

count_Book++;bookfile>>b1[count_Book].number>>b1[count_Book].title>>b1[count_Book].writer>>b1[count_Book].grade>>b1[count_Book].ISBNno>>b1[count_Book].press>>b1[count_Book].page;

}

bookfile.close();

}

voidBook:

:

add()

{//存入对象数组中

strcpy(b1[count_Book].number,number);

strcpy(b1[count_Book].title,title);

strcpy(b1[count_Book].writer,writer);

strcpy(b1[count_Book].grade,grade);

b1[count_Book].ISBNno=ISBNno;

strcpy(b1[count_Book].press,press);

b1[count_Book].page=page;

count_Book++;

}

voidBook:

:

modify(intindex)

{

strcpy(b1[index-1].number,number);

strcpy(b1[index-1].title,title);

strcpy(b1[index-1].writer,writer);

strcpy(b1[index-1].grade,grade);

b1[index-1].ISBNno=ISBNno;

strcpy(b1[index-1].press,press);

b1[index-1].page=page;

}

voidBook:

:

del(intindex){

//前移其后记录

for(inti=index;i<=count_Book-1;i++)

{

strcpy(b1[i-1].number,b1[i].number);

strcpy(b1[i-1].title,b1[i].title);

strcpy(b1[i-1].writer,b1[i].writer);

strcpy(b1[i-1].grade,b1[i].grade);

b1[i-1].ISBNno=b1[i].ISBNno;

strcpy(b1[i-1].press,b1[i].press);

b1[i-1].page=b1[i].page;

}

count_Book--;

}

voidBook:

:

save()

{

ofstreambookfile;

bookfile.open("图书类信息.dat");

for(inti=0;i<=count_Book-1;i++)

bookfile<

bookfile.close();}

3.3视频类的实现

Video.h

classVideo:

publicBase

{

public:

charnumber[20];//编号

chartitle[11];//标题

charwriter[8];//作者

chargrade[20];//评级

charname;//出品人姓名

chartime;//出品年份

intduration;//视频时长

voidread();

voidadd();

voidmodify(int);

voiddel(int);

voidsave();

};

Video.cpp

voidVideo:

:

read()

{

fstreamvideofile("班级信息.dat",ios:

:

in|ios:

:

out);

videofile>>v1[count_Video].number>>v1[count_Video].title>>v1[count_Video].writer>>v1[count_Video].grade>>v1[count_Video].name>>v1[count_Video].time>>v1[count_Video].duration;

while(!

videofile.eof())

{

count_Video++;videofile>>v1[count_Video].number>>v1[count_Video].title>>v1[count_Video].writer>>v1[count_Video].grade>>v1[count_Video].name>>v1[count_Video].time>>v1[count_Video].duration;

}

videofile.close();

}

voidVideo:

:

add()

{//存入对象数组中

strcpy(v1[count_Video].number,number);

strcpy(v1[count_Video].title,title);

strcpy(v1[count_Video].writer,writer);

strcpy(v1[count_Video].grade,grade);

strcpy(v1[count_Video].name,name);

strcpy(v1[count_Video].time,time);

v1[count_Video].duration=duration;count_Video++;

}

voidVideo:

:

modify(intindex)

{

strcpy(v1[index-1].number,number);

strcpy(v1[index-1].title,title);

strcpy(v1[index-1].writer,writer);

strcpy(v1[index-1].grade,grade);

strcpy(v1[index-1].name,name);

strcpy(v1[index-1].time,time);

v1[index-1].duration=duration;

}

voidVideo:

:

del(intindex)

{

//前移其后记录

for(inti=index;i<=count_Video-1;i++)

{

strcpy(v1[i-1].number,v1[i].number);

strcpy(v1[i-1].title,v1[i].title);

strcpy(v1[i-1].writer,v1[i].writer);

strcpy(v1[i-1].grade,v1[i].grade);

strcpy(v1[i-1].name,v1[i].name);

strcpy(v1[i-1].time,v1[i].time);

v1[i-1].duration=v1[i].duration;

}

count_Video--;

}

voidVideo:

:

save()

{

ofstreamvideofile;

videofile.open("班级信息.dat");

for(inti=0;i<=count_Video-1;i++)

videofile<

videofile.close();

}

 

3.4图画类的实现

Painting.h

classPainting:

publicBase

{

public:

charnumber[20];//编号

chartitle[11];//标题

charwriter[8];//作者

chargrade[20];//评级

charnationality[20];//出品国籍

charsize[20];//作品大小

voidread();

voidadd();

voidmodify(int);

voiddel(int);

voidsave();

};

Painting.cpp

voidPainting:

:

read()

{

fstreampaitingfile("图画类信息.dat",ios:

:

in|ios:

:

out);

paintingfile>>p1[count_Painting].number>>p1[count_Painting].title>>p1[count_Painting].writer>>p1[count_Painting].grade>>p1[count_Painting].nationality>>p1[count_Painting].size;

while(!

paintingfile.eof())

{

count_Painting++;

paintingfile>>p1[count_Painting].number>>p1[count_Painting].title>>p1[count_Painting].writer>>p1[count_Painting].grade>>p1[count_Painting].nationality>>p1[count_Painting].size;

}

paintingfile.close();

}

voidPainting:

:

add()

{

//存入对象数组中

strcpy(p1[count_Painting].number,number);

strcpy(p1[count_Painting].title,title);

strcpy(p1[count_Painting].writer,writer);

strcpy(p1[count_Painting].grade,grade);

strcpy(p1[count_Painting].nationality,nationality);

strcpy(p1[count_Painting].size,size);

count_Painting++;

}

voidPainting:

:

modify(intindex)

{

strcpy(p1[index-1].number,number);

strcpy(p1[index-1].title,title);

strcpy(p1[index-1].writer,writer);

strcpy(p1[index-1].grade,grade);

strcpy(p1[index-1].nationality,nationality);

strcpy(p1[index-1].size,size);

}

voidPainting:

:

del(intindex)

{

//前移其后记录

for(inti=index;i<=count_Class-1;i++)

{

strcpy(p1[i-1].number,p1[i].number);

strcpy(p1[i-1].title,p1[i].title);

strcpy(p1[i-1].writer,p1[i].writer);

strcpy(p1[i-1].grade,p1[i].grade);

strcpy(p1[i-1].nationality,p1[i].nationality);

strcpy(p1[i-1].size,p1[i].size);

}

count_Painting--;

}

voidPainting:

:

save()

{

ofstreamPaintingfile;

Paintingfile.open("班级信息.dat");

for(inti=0;i<=count_Painting-1;i++)

Paintingfile<

Paintingfile.close();

}

3.5main.cpp

#include

#include

#include

#include

#include"Base.h"

#include"Book.h"

#include"Painting.h"

#include"Video.h"

constintMAXBOOK=10;

constintMAXPAINTING=200;

constintMAXVIDEO=10;

Bookb1[MAXBOOK];

Paintingp1[MAXPAINTING];

Videoc2[MAXVIDEO];

intcount_Book=0;

intcount_Painting=0;

intcount_Video=0;

Base*p=NULL;

charout;

//图书类管理子菜单

voidbook_manage()

{

intchoice,i=0;

boolquit=false;

while

(1)

{

system("cls");

cout<<"**********图书类管理子菜单**********"<

cout<<"1.添加图书信息"<

cout<<"2.修改图书信息"<

cout<<"3.删除图书信息"<

cout<<"0.退出"<

cout<<"************************************"<

cout<<"请输入所要操作的编号:

";

cin>>choice;

switch(choice)

{

case1:

{

Bookb2;

p=&b2;

cout<<"请输入编号、标题、作者、评级、ISBN号、出版社和页

数:

\n";

cin>>>b2.number>>b2.title>>b2.writer>>b2.grade>>b2.ISBNno>>

b2.press>>b2.page>>endl;

cout<<"是否保存图书信息?

(y/n)\n";

cin>>out;

if(out=='y')

{

p->add();

p->save();

}

break;

}

case2:

{

Bookb3;

p=&b3;

intindex;

for(inti=0;i

cout<

cout<<"请选择图书信息编号:

\n";

cin>>index;

cout<<"请输入要修改的标题、作者、评级、ISBN号、出版社和页

数:

";

cin>>b3.title>>b3.writer>>b3.grade>>b3.ISBNno>>b3.press>>b3.page;

cout<<"是否保存班级信息?

(y/n)\n";

cin>>out;

if(out=='y')

{

p->modify(index);

p->save();

}

break;

}

case3:

{

Classb4;

p=&b4;

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 小学教育 > 其它课程

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1