图书管理系统的C#代码(完整版)
- 格式:docx
- 大小:29.47 KB
- 文档页数:15
图书管理系统的C代码完整版GE GROUP system office room 【GEIHUA16H-GEIHUA GEIHUA8Q8-C#代码清单共1个项目,包含5个类。
项目: librarysystem类: Program.cs Readers.cs Manage.cs Menu.cs Publications.cs 主类代码:namespace librarysystem{ ///<summary>///类名:Program///功能:项目主类///时间:2015-11-19///</summary>class Program{static void Main(string[] args){Menu meu = new Menu(); meu.ShowMainMenu();Console.ReadLine();}}}出版物类代码:namespace librarysystem{ ///<summary>///类名:Publications///功能:馆藏出版物信息///时间:2015-11-19///</summary>class Publications{/*出版物编号*/private string PublicationISBN;public string PublicationIsbn{get{return PublicationISBN; }set{PublicationISBN = value; }}/*出版物名称*/public string PublicationName;/*出版物作者或出版机构*/public string PublicationAuthor;/*出版物在架状态*/public bool PublicationStatus;/*出版物类型*/public string PublicationType;public Publications(){}public Publications(string PublicationISBN,string PublicationName,string PublicationAuthor,string PublicationType,bool PublicationStatus){this. PublicationISBN = PublicationISBN;this.PublicationName = PublicationName;this.PublicationAuthor = PublicationAuthor;this.PublicationType = PublicationType;this.PublicationStatus = PublicationStatus;}}}读者类代码:namespace librarysystem{ ///<summary>///类名:Readers///功能:已获取权限读者的信息///时间:2015-11-19///</summary>class Readers{private string ReaderID;public string ReaderId{get{return ReaderID;}set{ReaderID = value;}}public string ReaderName;public string ReaderSex;public string ReaderDepartment;public string ReaderMajor;public string[] BowPublication = new string[10]{"","","","","","","","","",""};public Readers(){}public Readers(string ReaderID, string ReaderName, string ReaderSex, string ReaderDepartment, string ReaderMajor){this.ReaderID = ReaderID;this.ReaderName = ReaderName;this.ReaderSex = ReaderSex;this.ReaderDepartment = ReaderDepartment;this.ReaderMajor = ReaderMajor;}}}管理类代码:namespace librarysystem{ ///<summary>///类名:Manage///功能:管理员执行图书管理操作///时间:2015-11-19///</summary>class Manage{public bool BorrowFlag = false;/*借阅操作成功标志*/public bool ReturnFlag = false;/*归还操作成功标志*/public Publications pub_search;/*保存查询到的出版物*/public Readers Red_valid;/*保存查询到的合法用户*//*声明馆藏出版物数组*/public Publications[] pubs=new Publications[200];/*声明注册读者数组*/public Readers[] reds=new Readers[30];/*实例化馆藏出版物对象*/public Publications pub0 = new Publications("000000","C#从入门到精通","明日科技","书籍",true);public Publications pub1 = new Publications("000001", "数值分析", "李清朗", "书籍", true);public Publications pub2 = new Publications("000002", "模式识别", "张学工", "书籍", true);public Publications pub3 = new Publications("000003", "中国国家地理", "地理科学院", "杂志", true);public Publications pub4 = new Publications("000004", "意林", "长春市文学艺术界联合会 ", "杂志", true);public Publications pub5 = new Publications("000005", "四川大学报", "四川大学", "报纸", true);public Publications pub6 = new Publications("000006", "经济学人", "伦敦经济学人报纸有限公司", "杂志", true);public Publications pub7 = new Publications("000007", "计算机网络", "谢希仁", "书籍", true);public Publications pub8 = new Publications("000008", "红楼梦", "曹雪芹", "书籍", true);public Publications pub9 = new Publications("000009", "新东方雅思培训课程", "俞敏洪", "音像制品", true);public Publications pub10 = new Publications("000010", "MATLAB实用教程", "张世杰", "音像制品", true);/*实例化已注册读者对象*/public Readers red0 = new Readers(, "李华", "男", "电子信息学院", "电子与通信工程");public Readers red1 = new Readers(, "王鹏", "男", "物理学院", "微电子学");public Readers red2 = new Readers(, "张建豪", "男", "数学学院", "现代数学分析");public Readers red3 = new Readers(, "陈莉", "女", "化学化工学院", "化学分析");public Readers red4 = new Readers(, "吴娜", "女", "医学院", "口腔医学");public Readers red5 = new Readers(, "宋雅茹", "女", "电子信息学院", "光学工程");/*初始化出版物数组*/public void PublicationsInitial(){pubs[0] = pub0;pubs[1] = pub1;pubs[2] = pub2;pubs[3] = pub3;pubs[4] = pub4;pubs[5] = pub5;pubs[6] = pub6;pubs[7] = pub7;pubs[8] = pub8;pubs[9] = pub9;pubs[10] = pub10;}/*初始化读者数组*/public void ReadersInitial() {reds[0] = red0;reds[1] = red1;reds[2] = red2;reds[3] = red3;reds[4] = red4;reds[5] = red5;}/*查询图书操作*/public bool SearchPublications(){string Pub_Name;bool SearchFlag = false;Pub_Name = Console.ReadLine();foreach (Publications pub in pubs){if (pub != null && pub.PublicationName == Pub_Name) {SearchFlag = true;pub_search = pub;}}return SearchFlag;}/*借阅图书操作*/public void Borrow(){string Red_Name;string Pub_Name;bool ReaderFlag = false;Red_Name = Console.ReadLine();foreach (Readers red in reds){if (red != null && red.ReaderName == Red_Name){ReaderFlag = true;Red_valid = red;}}if (ReaderFlag){Console.Write("请输入您需要借阅出版物的名称:");Pub_Name = Console.ReadLine();foreach (Publications pub in pubs){if (pub != null && pub.PublicationName == Pub_Name) {BorrowFlag = true;pub.PublicationStatus = false;AddToReders(pub.PublicationName, Red_valid);}}}else{Console.WriteLine("抱歉,您是非法读者,不能借阅图书"); }}/*归还图书操作*/public void Return(){string Red_Name;string Pub_Name;bool ReaderFlag = false;Red_Name = Console.ReadLine();foreach (Readers red in reds){if (red != null && red.ReaderName == Red_Name){ReaderFlag = true;Red_valid = red;}}if (ReaderFlag){Console.Write("请输入您需要归还出版物的名称:");Pub_Name = Console.ReadLine();foreach (Publications pub in pubs){if (pub != null && pub.PublicationName == Pub_Name) {for (int i = 0; i < 10;i++ ){if (Red_valid.BowPublication[i] == Pub_Name) {ReturnFlag = true;pub.PublicationStatus = true;RemoveFromReders(Pub_Name, Red_valid); }}}}}else{Console.WriteLine("抱歉,您是非法读者,无归还图书信息"); }}/*添加图书到读者*/private void AddToReders(string PublicationName, Readers red) {/*设置借阅上限为10本*/for (int i = 0; i < 10; i++){if (red != null && red.BowPublication[i]==""){red.BowPublication[i] = PublicationName;break;}}}/*从读者对象中移除图书*/private void RemoveFromReders(string PublicationName, Readers red){/*设置借阅上限为10本*/for (int i = 0; i < 10; i++){if (red != null && red.BowPublication[i] == PublicationName){red.BowPublication[i] = red.BowPublication[i+1]; }}}/*新书入库操作*/public void AddPublications(Publications pub){for (int i = 11; i < 200; i++){if(pubs[i]==null){pubs[i] = pub;}}}/*添加新读者操作*/public void AddReaders(Readers red) {for (int i = 6; i < 30; i++){if (reds[i] == null){reds[i] = red;}}}/*查询读者信息*/public void RedIndex(){string Red_Name;bool ReaderFlag = false;Red_Name = Console.ReadLine();foreach (Readers red in reds){if (red != null && red.ReaderName == Red_Name) {ReaderFlag = true;Red_valid = red;}}if (!ReaderFlag){Console.WriteLine("抱歉,您是非法读者,无法查到您的借阅信息");}}}}菜单类代码:namespace librarysystem{ ///<summary>///类名:Menu///功能:显示服务页面///时间:2015-11-19///</summary>class Menu{//创建一个具体的管理对象Manage mag = new Manage();//声明一个读者对象Readers red;//声明一个出版物对象Publications pub;public void ShowMainMenu(){mag.PublicationsInitial();mag.ReadersInitial();Console.WriteLine("欢迎使用图书管理系统V1.0");Console.WriteLine("-------------------------------------------------------------------");Console.WriteLine("1.查询图书");Console.WriteLine("2.借书服务");Console.WriteLine("3.还书服务");Console.WriteLine("4.新出版物入库");Console.WriteLine("5.录入新读者");Console.WriteLine("6.查询读者的借阅信息");Console.WriteLine("7.退出管理系统");Console.WriteLine("-------------------------------------------------------------------");bool flag;do{flag = false;Console.WriteLine("请选择:");string key = Console.ReadLine();switch (key){case"1":Console.Write("请输入需要查询图书的书名:");ShowPubInfo();break;case"2":Console.Write("请输入您的姓名:");mag.Borrow();ShowBorrowInfo();break;case"3":Console.Write("请输入您的姓名:");mag.Return();ShowReturnInfo();break;case"4":Console.WriteLine("请按照提示逐步输入需要入库出版物的信息……");ShowAddPublications();break;case"5":Console.WriteLine("请按照提示逐步输入新注册读者的信息……");ShowAddReaders();break;case"6":Console.Write("请输入您的姓名: ");mag.RedIndex();ShowRedPubInfo(mag.Red_valid);break;case"7":flag = false;break;default:Console.WriteLine("无此业务,是否重新选择(y/n)");string answer = Console.ReadLine();if (answer != "y"){flag = false;}else{flag = true;}break;}} while (flag);}/*显示查询到的出版物信息*/public void ShowPubInfo(){if (mag.SearchPublications()){Console.WriteLine("您要查询的出版物信息:");Console.WriteLine("-------------------------------------------------------------------");Console.WriteLine("编号: " +mag.pub_search.PublicationIsbn);Console.WriteLine("出版物名字: " +mag.pub_search.PublicationName);Console.WriteLine("出版物作者: " +mag.pub_search.PublicationAuthor);Console.WriteLine("出版物类型: " +mag.pub_search.PublicationType);if (mag.pub_search.PublicationStatus){Console.WriteLine("出版物状态:在架,可借");}else{Console.WriteLine("出版物状态:未在架,不可借");}Console.WriteLine("-------------------------------------------------------------------");Console.WriteLine("");Console.WriteLine("");Console.WriteLine("是否办理其他业务(y/n)");string answer = Console.ReadLine();if (answer == "y"){ShowMainMenu();Console.WriteLine();}else{Console.WriteLine("结束");}}else{Console.WriteLine("抱歉,未找到该图书!");Console.WriteLine("是否办理其他业务(y/n) ");string answer = Console.ReadLine();if (answer == "y"){ShowMainMenu();Console.WriteLine();Console.WriteLine();}else{Console.WriteLine("结束");}}}/*显示借阅操作结果*/public void ShowBorrowInfo(){if (mag.BorrowFlag){Console.WriteLine("恭喜,借阅成功!"); ShowRedPubInfo(mag.Red_valid);}else{Console.WriteLine("抱歉,借阅失败!");Console.WriteLine("是否办理其他业务(y/n) ");string answer = Console.ReadLine();if (answer == "y"){ShowMainMenu();}else{Console.WriteLine("结束");}}}/*显示归还操作结果*/public void ShowReturnInfo(){if (mag.ReturnFlag){Console.WriteLine("恭喜,归还成功!");ShowRedPubInfo(mag.Red_valid);}else{Console.WriteLine("抱歉,归还失败!");Console.WriteLine("是否办理其他业务(y/n) ");string answer = Console.ReadLine();if (answer == "y"){ShowMainMenu();}else{Console.WriteLine("结束");}}}public void ShowRedPubInfo(Readers red){Console.WriteLine("当前你的借阅信息如下:");Console.WriteLine("--------------------------------------------------------------------");Console.WriteLine("编号: " + red.ReaderId);Console.WriteLine("姓名: " + red.ReaderName);Console.WriteLine("性别: " + red.ReaderSex);Console.WriteLine("所在院系: " + red.ReaderDepartment);Console.WriteLine("主修专业: " + red.ReaderMajor);Console.Write("已借图书: ");for (int{if (red.BowPublication[i] != ""){Console.Write(" "+red.BowPublication[i]);}}Console.WriteLine("");Console.WriteLine("--------------------------------------------------------------------");Console.WriteLine("");Console.WriteLine("是否办理其他业务(y/n)");string answer = Console.ReadLine();if (answer == "y"){ShowMainMenu();}else{Console.WriteLine("结束");}}/*显示新出版物入库的信息*/public void ShowAddPublications(){pub = new Publications();Console.Write("请输入出版物的编号: "); pub.PublicationIsbn=Console.ReadLine();Console.Write("请输入出版物的名称: ");pub.PublicationName = Console.ReadLine();Console.Write("请输入出版物的编者: ");pub.PublicationAuthor = Console.ReadLine();Console.Write("请输入出版物的类型: ");pub.PublicationType = Console.ReadLine(); pub.PublicationStatus = true;mag.AddPublications(pub);Console.WriteLine("新出版物入库成功!");Console.WriteLine("是否办理其他业务(y/n) ");string answer = Console.ReadLine();if (answer == "y"){ShowMainMenu();Console.WriteLine();Console.WriteLine();}else{Console.WriteLine("结束");}}/*显示新读者注册的信息*/public void ShowAddReaders(){red = new Readers();Console.Write("请输入新注册读者的编号: "); red.ReaderId = Console.ReadLine();Console.Write("请输入新注册读者的姓名: "); red.ReaderName= Console.ReadLine();Console.Write("请输入新注册读者的性别: ");red.ReaderSex = Console.ReadLine();Console.Write("请输入新注册读者的院系: "); red.ReaderDepartment = Console.ReadLine();Console.Write("请输入新注册读者的专业: "); red.ReaderMajor = Console.ReadLine();for(int i=0;i<10;i++){red.BowPublication[i]="";}mag.AddReaders(red);Console.WriteLine("新读者注册成功!");Console.WriteLine("是否办理其他业务(y/n) ");string answer = Console.ReadLine();if (answer == "y"){ShowMainMenu();Console.WriteLine();Console.WriteLine();}else{Console.WriteLine("结束"); }}}}。
c图书管理系统实验报告C图书管理系统实验报告摘要:本实验报告通过对C图书管理系统的设计、实现和测试,展示了该系统的功能和性能。
实验结果表明,C图书管理系统具有良好的稳定性和高效性,能够满足图书管理的需求。
1. 引言图书管理系统是一个用于管理图书信息、借阅记录和读者信息的软件系统。
随着图书馆规模的扩大和信息化的发展,图书管理系统的重要性日益凸显。
C图书管理系统是一个基于C语言开发的图书管理软件,具有良好的稳定性和高效性。
2. 设计与实现C图书管理系统的设计和实现主要包括以下几个方面:(1)数据库设计:设计图书信息、读者信息和借阅记录等数据库表结构,确保数据存储的有效性和完整性。
(2)功能实现:实现图书信息的录入、查询和修改功能,实现读者信息的管理和借阅记录的管理功能。
(3)界面设计:设计用户友好的界面,方便用户进行操作和查询。
3. 功能测试在实验中,我们对C图书管理系统进行了功能测试,主要包括以下几个方面:(1)图书信息管理:测试图书信息的录入、查询和修改功能,确保信息的准确性和完整性。
(2)读者信息管理:测试读者信息的录入、查询和修改功能,确保信息的准确性和完整性。
(3)借阅记录管理:测试借阅记录的录入、查询和修改功能,确保记录的准确性和完整性。
4. 性能测试在实验中,我们对C图书管理系统进行了性能测试,主要包括以下几个方面:(1)系统稳定性:测试系统在长时间运行中是否会出现崩溃或卡顿现象,确保系统的稳定性。
(2)响应速度:测试系统在查询和操作时的响应速度,确保系统的高效性。
5. 实验结果经过功能测试和性能测试,我们得出了以下实验结果:(1)C图书管理系统具有良好的稳定性,长时间运行中未出现崩溃或卡顿现象。
(2)C图书管理系统具有较快的响应速度,在查询和操作时能够快速响应用户的需求。
6. 结论C图书管理系统在设计、实现和测试中表现出良好的功能和性能,能够满足图书管理的需求。
通过本实验报告的展示,我们相信C图书管理系统将会成为图书馆管理的重要工具,为图书馆的信息化建设提供有力支持。
图书管理系统的设计C 课程设计一、教学目标本课程的设计目标是使学生掌握图书管理系统的设计与实现。
具体目标如下:1.理解图书管理系统的需求和功能。
2.掌握常用的数据结构和算法,并能够应用于图书管理系统的设计。
3.了解数据库的基本概念,并能够使用数据库进行图书管理。
4.能够使用C语言进行程序设计,包括编码、调试和测试。
5.能够使用数据库管理系统进行数据的存储和管理。
情感态度价值观目标:1.培养学生对计算机科学和编程的兴趣和热情。
2.培养学生解决问题的能力和团队合作的精神。
二、教学内容教学内容将按照以下大纲进行:1.图书管理系统需求分析:介绍图书管理系统的功能和需求,包括图书的增删查改等操作。
2.数据结构的选择:介绍常用的数据结构,如数组、链表、树等,并分析其在图书管理系统中的应用。
3.算法的选择:介绍常用的算法,如搜索、排序等,并分析其在图书管理系统中的应用。
4.数据库的设计:介绍数据库的基本概念,并学习如何使用数据库管理系统进行数据的存储和管理。
5.图书管理系统的实现:使用C语言进行图书管理系统的编码、调试和测试。
三、教学方法将采用多种教学方法进行教学,以激发学生的学习兴趣和主动性:1.讲授法:用于讲解基本概念和理论知识。
2.案例分析法:通过分析实际案例,使学生更好地理解和应用所学知识。
3.实验法:通过实际操作和实验,使学生掌握图书管理系统的实现和测试。
四、教学资源将选择和准备以下教学资源:1.教材:选用《C程序设计》作为主教材,用于学习C语言编程基础。
2.参考书:选用《数据结构与算法分析》和《数据库原理》作为参考书,用于深入学习数据结构和算法以及数据库的知识。
3.多媒体资料:制作PPT和教学视频,用于讲解理论知识。
4.实验设备:准备计算机和数据库管理系统,用于实际操作和实验。
五、教学评估教学评估将采用多种方式进行,以全面反映学生的学习成果:1.平时表现:评估学生的课堂参与度、提问回答和小组讨论的表现,以考察学生的学习态度和积极性。
C图书管理系统源代码 Standardization of sany group #QS8QHH-HHGX8Q8-GNHHJ8-HHMHGN#图书管理系统系统功能:1.借书:根据借书人提出的图书编号(id)查询该图书,如果该图书现存量(store)不为0,则提示输入借阅者的学号(num),为借书人办理借书手续,提示用户该书已被借出。
2.归书:根据借书人的学号查询该读者的信息,若有该读者,则提示输入所借书籍的编号(id),为该读者办理还书手续,提示该书已还。
3.书籍管理:弹出书籍管理界面,输入所要执行操作的号码:(1)增加书籍:弹出注册新书的窗口,按照提示输入所增加书籍的信息,最后,提示用户该书已被注册。
(2)删除书籍:弹出删除书籍的窗口,输入所要删除书籍的编号(id),输出该书的信息,确认是否删除该书,1为删除,0为放弃。
(3)修改书籍:弹出修改书籍的窗口,输入所要修改书籍的编号(id),输出该书的信息,确认是否修改该书,1为修改,0为放弃。
之后按照提示重新输入书籍的信息。
4.读者管理:弹出读者管理界面,输入所要执行操作的号码:(1)增加读者:弹出注册读者的窗口,按照提示输入所增加读者的信息,最后,提示用户该读者已被注册。
(2)删除书籍:弹出删除读者的窗口,输入所要删除读者的学号(num),输出该读者的信息,确认是否删除该读者,1为删除,0为放弃。
(3)修改书籍:弹出修改读者的窗口,输入所要修改读者的学号(num),输出该读者的信息,确认是否修改该读者,1为修改,0为放弃。
之后按照提示重新输入读者的信息。
5.搜索:此搜索包括两方面的搜索,书籍搜索以及读者搜索,弹出搜索的窗口,按照提示输入所要搜索的内容,1为书籍搜索,2为读者搜索:(1)搜索书籍:弹出搜索书籍的窗口,按照提示输入所要搜索的方式,包括按<1>书名搜索,<2>书号搜索,<3>作者搜索,<4>出版社搜索,<5>出版时间搜索;根据所选方式输入相应的内容,若是该书籍存在,则输出该书籍的信息,否则,返回主界面。
c图书管理系统课程设计一、课程目标知识目标:1. 理解图书管理系统的基本概念和功能,掌握其在我国图书馆的应用现状。
2. 学会使用数据库管理图书信息,掌握基本的SQL查询语句。
3. 了解并掌握C语言编程在图书管理系统中的应用。
技能目标:1. 能够运用所学知识设计并实现一个简单的图书管理系统。
2. 提高问题分析能力,通过C语言编程解决图书管理中的实际问题。
3. 培养团队协作能力,通过分组讨论、共同开发完成课程项目。
情感态度价值观目标:1. 培养学生对图书管理工作的兴趣,提高对图书馆工作的认识。
2. 增强学生的信息素养,使其认识到信息管理在现代图书馆工作中的重要性。
3. 培养学生积极参与、乐于探究的学习态度,激发创新意识。
课程性质:本课程为实践性较强的课程,以C语言为基础,结合数据库知识,让学生在实际操作中掌握图书管理系统的设计与实现。
学生特点:学生具备一定的C语言基础和数据库知识,对实际应用有较高的兴趣,喜欢动手实践。
教学要求:注重理论与实践相结合,以学生为主体,鼓励学生主动参与、积极思考、动手实践。
通过课程学习,使学生能够独立设计并实现一个简单的图书管理系统,提高其编程能力和问题解决能力。
二、教学内容1. 理论知识:- 图书管理系统概述:介绍图书管理系统的基本概念、功能及在我国图书馆的应用现状。
- 数据库基础:回顾数据库的基本概念、数据模型、关系数据库及其设计方法。
- C语言编程:复习C语言基础知识,强调其在图书管理系统中的应用。
2. 实践操作:- 数据库设计:学习设计图书管理系统的数据库,包括表结构设计、数据完整性约束等。
- C语言编程实践:运用C语言编写图书管理系统的主要功能模块,如图书信息录入、查询、删除等。
- 项目开发:分组进行项目实践,培养学生团队协作能力,完成一个简单的图书管理系统。
3. 教学大纲:- 第一周:图书管理系统概述,复习C语言基础知识。
- 第二周:数据库基础,设计图书管理系统的数据库。
原创C语言图书馆管理系统源代码介绍图书馆作为一个重要的知识储备和学习场所,必须进行有效的管理和组织。
使用C语言编写的图书馆管理系统可以帮助图书馆实现自动化的借阅、归还和管理功能。
本文将介绍一个原创的C语言图书馆管理系统的源代码。
功能概述这个图书馆管理系统具有以下核心功能: - 图书管理:包括添加图书、删除图书、查询图书等操作。
- 借阅管理:可以进行借阅操作,记录借阅者和借阅时间。
- 归还管理:可以进行归还操作,并更新图书的可借状态。
- 用户管理:管理借阅者的信息,包括添加用户、删除用户、查询用户等操作。
数据结构设计该图书馆管理系统使用了以下几种数据结构: 1. 图书(Book)结构体:包含图书的ID、书名、作者、可借状态等字段。
2. 用户(User)结构体:包含用户的ID、姓名、地址等字段。
3. 借阅记录(BorrowRecord)结构体:包含借阅者ID、图书ID、借阅时间等字段。
系统流程整个系统的流程可以分为以下几个步骤: 1. 用户打开系统,进入主菜单。
2. 用户选择不同的功能选项(如图书管理、借阅管理、用户管理等)。
3. 根据用户选择的功能,进入相应的功能界面。
4. 用户可以根据提示,输入相应的信息进行图书管理、借阅管理或用户管理操作。
5. 用户完成操作后,可以选择返回主菜单或退出系统。
代码实现以下是一个简化版的C语言图书馆管理系统的源代码:```c #include <stdio.h>// 定义结构体 struct Book { int id; char name[50]; char author[50]; int isAvailable; };struct User { int id; char name[50]; char address[100]; };struct BorrowRecord { int userId; int bookId; char borrowDate[20]; };// 函数声明 void addBook(); void deleteBook(); void searchBook(); void borrowBook(); void returnBook(); void addUser(); void deleteUser(); void searchUser();int main() { int choice;do {// 显示主菜单printf(\。
c图书管理系统课程设计一、教学目标本课程旨在让学生了解和掌握图书管理系统的基本原理和操作方法,培养学生运用计算机技术管理图书的能力。
具体目标如下:1.知识目标:使学生了解图书管理系统的起源、发展及其基本组成部分,掌握图书管理系统的主要功能和操作方法。
2.技能目标:培养学生能够熟练使用图书管理系统,进行图书的录入、查询、修改和删除等操作,并能进行简单的系统维护。
3.情感态度价值观目标:培养学生对图书管理工作的热爱和敬业精神,提高学生服务于社会、服务于他人的意识。
二、教学内容本课程的教学内容主要包括以下几个部分:1.图书管理系统的基本概念:介绍图书管理系统的发展历程、基本功能和组成部分。
2.图书管理系统的操作方法:讲解图书的录入、查询、修改和删除等基本操作,以及系统的维护和升级。
3.图书管理系统的应用案例:分析实际工作中的图书管理案例,让学生了解图书管理系统在实际工作中的应用。
4.图书管理系统的开发:介绍图书管理系统的开发流程,让学生了解图书管理系统的开发过程。
三、教学方法为了提高教学效果,本课程将采用以下几种教学方法:1.讲授法:通过讲解教材,使学生掌握图书管理系统的基本概念和原理。
2.案例分析法:分析实际工作中的图书管理案例,让学生了解图书管理系统的应用。
3.实验法:让学生亲自动手操作图书管理系统,提高学生运用所学知识解决实际问题的能力。
4.讨论法:学生进行分组讨论,培养学生的团队协作能力和解决问题的能力。
四、教学资源为了支持本课程的教学,我们将准备以下教学资源:1.教材:选用国内权威出版社出版的图书管理系统相关教材。
2.参考书:提供相关的参考书籍,丰富学生的知识体系。
3.多媒体资料:制作精美的PPT,辅助讲解和展示图书管理系统的操作界面及功能。
4.实验设备:准备计算机及相关设备,让学生进行实际操作。
五、教学评估为了全面、客观地评估学生的学习成果,本课程将采用以下几种评估方式:1.平时表现:通过观察学生在课堂上的参与程度、提问回答等情况,评估学生的学习态度和理解程度。
C#代码清单共1个项目,包含5个类。
项目: librarysystem类:主类代码:namespace librarysystem{ PublicationISBN = PublicationISBN;= PublicationName;= PublicationAuthor;= PublicationType;= PublicationStatus;}}}读者类代码:namespace librarysystem{ 询图书");("2.借书服务");("3.还书服务");("4.新出版物入库");("5.录入新读者");("6.查询读者的借阅信息");("7.退出管理系统");("-------------------------------------------------------------------");bool flag;do{flag = false;("请选择:");string key = ();switch (key){case"1":("请输入需要查询图书的书名:");ShowPubInfo();break;case"2":("请输入您的姓名:");();ShowBorrowInfo();("请输入您的姓名:");();ShowReturnInfo();break;case"4":("请按照提示逐步输入需要入库出版物的信息……");ShowAddPublications();break;case"5":("请按照提示逐步输入新注册读者的信息……");ShowAddReaders();break;case"6":("请输入您的姓名: ");();ShowRedPubInfo;break;case"7":flag = false;break;default:("无此业务,是否重新选择(y/n)");string answer = ();if (answer != "y"){flag = false;}else{flag = true;}break;}} while (flag);}/*显示查询到的出版物信息*/public void ShowPubInfo(){if ()){("您要查询的出版物信息:");("-------------------------------------------------------------------"); ("编号: " + ("出版物名字: " + ("出版物作者: " + ("出版物类型: " + if {("出版物状态:在架,可借");else{("出版物状态:未在架,不可借");}("-------------------------------------------------------------------"); ("");("");("是否办理其他业务(y/n)");string answer = ();if (answer == "y"){ShowMainMenu();();}else{("结束");}}else{("抱歉,未找到该图书!");("是否办理其他业务(y/n)");string answer = ();if (answer == "y"){ShowMainMenu();();();}else{("结束");}}}/*显示借阅操作结果*/public void ShowBorrowInfo(){if{("恭喜,借阅成功!");ShowRedPubInfo;}{("抱歉,借阅失败!");("是否办理其他业务(y/n)");string answer = ();if (answer == "y"){ShowMainMenu();}else{("结束");}}}/*显示归还操作结果*/public void ShowReturnInfo(){if{("恭喜,归还成功!");ShowRedPubInfo;}else{("抱歉,归还失败!");("是否办理其他业务(y/n)");string answer = ();if (answer == "y"){ShowMainMenu();}else{("结束");}}}public void ShowRedPubInfo(Readers red){("当前你的借阅信息如下:");("--------------------------------------------------------------------"); ("编号: " + ;("姓名: " + ;("性别: " + ;("主修专业: " + ;("已借图书: ");for (int{if [i] != ""){(" "+[i]);}}("");("--------------------------------------------------------------------"); ("");("是否办理其他业务(y/n)");string answer = ();if (answer == "y"){ShowMainMenu();}else{("结束");}}/*显示新出版物入库的信息*/public void ShowAddPublications(){pub = new Publications();("请输入出版物的编号: ");=();("请输入出版物的名称: ");= ();("请输入出版物的编者: ");= ();("请输入出版物的类型: ");= ();= true;(pub);("新出版物入库成功!");("是否办理其他业务(y/n)");string answer = ();if (answer == "y"){ShowMainMenu();();}else{("结束");}}/*显示新读者注册的信息*/public void ShowAddReaders(){red = new Readers();("请输入新注册读者的编号: "); = ();("请输入新注册读者的姓名: "); = ();("请输入新注册读者的性别: "); = ();("请输入新注册读者的院系: "); = ();("请输入新注册读者的专业: "); = ();for(int i=0;i<10;i++){[i]="";}(red);("新读者注册成功!");("是否办理其他业务(y/n) ");string answer = ();if (answer == "y"){ShowMainMenu();();();}else{("结束");}}}}。
图书管理系统代码(c语言)#include〈stdio. h>#include〈stdlib・ h>#include〈string・ h>struct book{int num;char bname[50];char wname[20];char press[50^;char sort[50]:int time;float price;struct book *next;};struct book *creatbook() ; //创建链表struct book * addbook (structbook *head) ; //添加图书int yanzheng(struct book *head, int m) ; //验证新添加的图书编码是否已存在void deletebook (struct book *head) ; //删除图书void fprint (struct book *head) : //将链表写入文件struct book *load() ; // 从文件中读取信息并建成链表void print_book(struct book *head) : //将链表信息输出void chaxun(struct book *head) ; //查询图书信息void num_chaxun(struct book *head) ; //按图书编号查询图书void wname_chaxun(struct book *head) ; //按作者名查询图书voidsort_chaxun(struct book *head) ; //按类另lj查询图书void time_chaxun(structbook *head) ; //按出版时间查询图书void bname_chaxun(struct book *head); //按图书名査询图书void xiugai (struct book *head); //修改图书信息void paixu(struct book *head) ; //对图书进行排序void num_paixu(struct book ♦head); 〃按图书编号排序void time_paixu(struct book *head) ; //按图书出版时间排序void price_paixu(struct book *head): //按图书价格排序void bname_paixu(struct book *head) ; //按图书名排序void wname_paixu(struct book *head) ; //按作者名排序int main()int choice, n, x, y=l, c, cl=123456;char a, d, b[10], bl[10]="201102520116";struct book *head=NULL;while(y){system("cis");printf ("\n\n\n\n\n\n\n");printf (z ********** 欢迎光临**********\n\n,z);printf (,z ********************** 图书信息管理系统printf C\n\n');printf C ™=_1—用户登录=_==\十);二二二二二二二二二二二二0-退出系统二二二二二二二二二二二\『);printf Cprintf f请输入您的选择「);scanf (,z%d,z, &n);printf("\n");getchar ();switch(n) {case 0:y 二0;break;case 1:printf C请输入您的用户名:〃);gets(b);printf C\n");printf C请输入您的密码:“);scanf("%d", &c);printf("\n");if(strcmp(b, bl)!=0 |c!=cl){printf C验证失败,请重新输入!\n〃);scanf &d);getchar ();system("cls");}else {printf ("验证通过!请按Enter键进入!\n"); scanf("%c", &d);getchar ();x二1;while(x){ system("cis");printf C --------------------- \n"); printff *图书信息管理系统*\n 〃); printf C --------------------- \n\rT); • I • '.I"■、』•-1"• I • '.I" ■、』•-1"■、/• I • '.I" ■、』•-1"■、/• I • '.I" ■、』•-1"■、/• I • '.I" ■、』•-1" ■、/ • I • '.I" \ \1 •viw vaw vVw vTw vVwvaw vgW viw vaw vVw vTw vVwvaw vgW viw vaw vVw vTw vVwvaw vgW viw vaw vVw vTw vVwvaw vgW viw vaw vVw vTw vVw vaw vgW viw vaw vVw vTw viw »Tw 、『(、『]•、.• \ \ 1 • viw viw vaw vTw viw viw viw viw vTW viwvaw vaw viw viw viw viw vTW viw vaw vaw viw viw viw viw vTW viw vaw vaw viw viw viw viw vTW viw vaw vaw viw viw viw viw vTW viw vaw vaw viw »Tw•”f.・•工・•」・• —I" ■、尸■、■•■、丿•工・•」・• —I"■、尸■、■•■、丿•工・•」・• —I"■、尸■、■•■、丿•工・•」・• —I" ■、尸■、■• ■、丿•工・•」・• —I"■、尸■、■• ■、丿•工・•」・• —I"■、,\ \1 •VBW VIW VIW VSW VBW VCW VIW VIW VIW VIW VBW VBW vYw VIW VIW VIW VIW VBW VBW vYwVIW VIW VIW VIW VBW VBW vYw V IW VIW VIW VIW VBW VBW vYwVIW VIW VIW VIW VBW VIW»Tw 、『(、[]• (_•・.l ・■、』•工・•丄• •」•• •丄••丄• •■l ・■、』•工・•丄• •」•• •丄••丄• •■1・■、』•工・•丄• •」•• •丄• •丄• •■1・■、』•工・•丄••」•• •丄••丄• •■1・■、』•工・•丄• •」•• •丄• •丄•■、』•工・•丄• •」.• \ \ 1 •v^w viw vaw vTw vawv^w viw vaw vaw vawv^w viw vaw vaw vawv^w viw vaw vaw vawv^w viw vaw vaw vawv^w viw vaw viw ^«w | I 、了]printf C 请输入所选择的序号:〃); scanf("%d", &choice); getchar (); system("cls"); switch(choice) case 0: x=0;break; case 1: head=load(); if (head=NULL) {printf C 文件为空,请先录入数据! \n 〃); getchar (); break; } else {head=addbook(head); printf ("添加成功! \n");printff 是否将新信息保存到文件?(y/n)\n 〃); scanf&a);printf (”II 1-添加图书 2-删除图书I\n\n");printf (" II 3-图书列表 4-图书排序 I \n\rT); printf (“II 3-查询图书 6-修改图书 I \n\rT); printf (“ II 7-录入数据 0-退岀系统 I \n\rT);printf Cprintf (”printf ("printf (”getchar ();switch(a){case , n,:break;case ' y‘ :fprint(head);printf ("保存成功! \n");getchar ();break;}break;}case 2:head=load();if (head=NULL) {printf C文件为空,请先录入数据! \n〃);getchar ();break;}else{deletebook(head);getchar ();break;}break;case 3:head=load();辻(head==NULL){printf ("文件为空,请先录入数据!\n");getchar ();break;}else{print_book(head);getchar ();break;}case 4:head二load ();辻(head==NULL) {printf ("文件为空,请先录入数据! \『);getchar ();break;}else{paixu (head);getchar ();}break;case 5:head二load ();辻(head==NULL){printf ("文件为空,请先录入数据!\n");getchar ();break;}else{chaxun(head);getchar ();}break;case 6:head=load();辻(head二二NULL){printf C文件为空,请先录入数据!\n");getchar ();break;}else {xiugai(head);getchar ();break;}break;case 7:printf (〃注意:输入图书编码为0时结束! \rT);head=creatbook ();printf r是否将输入的信息保存到文件以覆盖文件中已存在的信息?(y/n)\n");getchar ();scanf (“%c", &a);getchar ();switch(a){case ' n :break;case ' y‘ :fprint(head);printf ("保存成功! \n");getchar ();break;}break;default:printff您的输入有误,请重新输入! \n〃);getchar ();break;}}}break;default:printf("您的输入有误!请重新输入!\n〃);getchar ();break;}}}//录入数据并形成链表struct book *creatbook() {struct book *head, *tail, *p;int num, time, n;char bname[50], wname[20], press[50],sort[50];float price; int size=sizeof(struct book): head二tail二NULL; printfC请输入图书编号:〃);scanf&num);printff请输入图书名:〃);scanfbname);getchar ();printff请输入作者名:〃);scanf wname);getchar ();printfC请输入出版社:“);scanfpress);getchar ();printfC请输入类别:“);scanf (〃%s: sort);getchar ();printfC请输入出版时间:“);scanf&time);getchar ();printf ("请输入价格:");scanf("%f", &price);getchar ();while(l) {p= (struct book *)malloc(size);p->num=num;strcpy(p->bname, bname);strcpy(p->wname, wname);strcpy(p->press,press);strcpy(p->sort, sort);p->time二time;p->price=price;p->next二NULL;if (head=NULL)head二p;elsetail-〉next二p;tail=p;do{printff请输入图书编号:〃);scanf&num);n=yanzheng(head, num);辻(n=0)break;elseprintff您输入的编号已存在,请重新输入! \n〃); }while(1);if(num==0) break;else printfC请输入图书名:〃);scanfbname);getchar ();printff请输入作者名:〃);scanf wname);getchar ();printff请输入出版社:“);scanfpress);getchar ();printfC请输入类别:");scanfsort);getchar ();printfC请输入出版时间:”); scanf ("%d", &time);getchar ();printf ("请输入价格:”);scanf("%f", &price);getchar ();}}return head;}〃插入结点,并且插入后仍按一定顺序struct book *addbook (struct book *head) struct book *ptr, *pl, *p2, *p;char bname[50], wname[20], press[50_, sort[50];int size=sizeof(struct book):int num, time, n=l:float price;do{printff请输入图书编号:“);scanf&num);n=yanzheng(head, num);if (n=0)break;elseprintf (〃您输入的编号已存在,请重新输入! \n〃);}while(1);printf C请输入图书名:〃);scanfbname);getchar ();printf r请输入作者名:〃);scanf wname);getchar ();printf C请输入出版社:〃);scanfpress);getchar ();printfC请输入类别:〃);scanf(〃%s〃, sort);getchar ();printfC请输入出版时间:“);scanf &time);getchar ();printf ("请输入价格:”);scanf("%f", &price);getchar ();p= (struct book *)malloc(size);p->num=num;strcpy (p~>bname, bname);strcpy(p->wname, wname);strcpy (p->press, press);strcpy (p->sort, sort);p->time=time;p->price=price;p2=head;Ptr=p;while((ptr->num>p2->num)&&(p2-〉next!=NULL)){pl二p2;p2二p2-〉next;}if(ptr->num<=p2->num){if (head=p2)head二ptr;else {pl->next=ptr;p->next=p2;}}else {p2->next=ptr;p->next二NULL;}return head;}//验证添加的图书编号是否已存在int yanzheng(struct book *head, int m) {struct book *p;p=head;while(p!=NULL){if (p-'nunFp)break;p=p->next;}辻(p二二NULL)return 0;elsereturn 1;}//将新链表写入文件中void fprint (struct book *head){FILE *f p;char ch二'1’ ;struct book *pl;if ((fp 二 f open ("fl. txt", "w"))=NULL) {printf (,z File open error!\n z/):exit(0);}fputc(ch, fp);for(pl二head;pl;pl二pl->next) {fprintf (fp,,z%d %s %s %s %s %d %f\n,z, pl->num, pl->bname, pl->wname, pl->press,pl-〉sort,pl-〉time, pl-〉price);}fclose (fp);}//从文件中读取图书信息struct book *load()FILE *fp;char ch;struct book *head,*tail,*pl:head二tail二NULL;if ((fp 二 f open ("fl. txt", "r"))=NULL) {printf (,z File open error!\n z/):exit(O);}ch=fgetc (fp);辻(ch='l'){while(!feof(fp)) {pl=(struct book *)malloc(sizeof(struct book)):fscanf (fp, z,%d%s%s%s%s%d%f\n, &pl->num, pl->bname, pl->wname, pl- >press,pl-〉sort, &pl-〉time, &pl->price);辻(head二二NULL)head=pl;elsetail->next=pl;tail=pl;}tail-〉next二NULL;fclose (fp);return head;}elsereturn NULL;}〃将整个链表的信息输出void print_book(struct book *head) {struct book *ptr;辻(head=NULL) {printf ("\n 没有信息!\n");return;}printf r图书信息列表如下\n);printf C============================+)printfC编号图书名作者名出版社类别出版时间价格\n〃);for(ptr=head;ptr;ptr=ptr->next)printf (,z %d %s %s %s %s %d%・ 2f\n z/, ptr->num, ptr->bname, ptr->wname, ptr-〉press, ptr-〉sort, ptr->time, ptr-〉price);}printf CW);}//删除图书信息void deletebook(struct book *head) {int a;char b, ch二'1’ ;struct book *pl,*p2;FILE *fp;printff请输入要删除的图书编号:〃);scanf&a);pl=head;if (pl->num~a&&pl->next==NULL) { //对于文件中只有一组数据printfC是否清空文件!(y/n)\『);getchar ();scanf&b);getchar ();switch (b) {case ' n :break;case ' y‘ :if ((fp 二 f open ("fl. txt", "w"))=NULL) {printf (,z File open error!\n z,):exit(O);}fclose (fp);printf C文件已清空! \rT);}}else {while (pl->num!二a&&pl-〉next!二NULL) {p2二pl;pl=pl->next;}if (pl->next=NULL) {if (pl->num==a){p2-〉next二NULL;printfC是否确定从文件中彻底删除该图书?(y/n)\n,z); getchar ();scanf&b);switch (b) {case ' n :break;case ' y‘ :fprint(head);printf ("删除成功!\n");getchar ();break;}}else {printf (〃没有找到要删除的数据! \『);getchar ();}}else if(pl==head) {head=pl~>next:printf("是否确定从文件中彻底删除该图书?(y/n)\n"); getchar (); scanf &b);switch(b){case ' n :break;case ' y‘ :fprint (head);PrintfC 删除成功!\n〃);getchar ():break;}}else{p2-〉next二pl->next;printf("是否确定从文件中彻底删除该图书?(y/n)\n"); getchar ();scanf ("%c", &b);switch (b) { case ' n': break;case ' y,:fprint(head);printf ("删除成功!\n");getchar ();break;}}}}〃图书查询void chaxun(struct book *head) {int a;printf(”============================\n)printf C ** 1-按图书编号查询2-按图书名查询和<\『);printf (,z ** 3-按图书类别查询4-按作者名查询和<\n〃);printf C ** 5-按出版时间査询0-退出查询**\n");printf C============================\n );printf C请输入所选择的编号:〃);scanf&a);getchar ();switch(a){case 0:break;case 1:num_chaxun(head); break;case 2:bname_chaxun(head); break;case 3:sort_chaxun(head); break;case 4:wname_chaxun(head); break;case 5:t ime_chaxun(head); break;default:printf ("您的输入有误! \n"); break;}//按编号查询图书信息void num_chaxun(struct book *head){int a;struct book *p;printff请选择您要查询的图书编号:〃); scanf&a);getchar ();p二head;while(p!=NULL){if (p->num==a)break;p=p->next;}辻(p二二NULL){printfC没有找到该编号的图书!\n〃);}else {printfC你所查询的图书信息如下\n〃); printf C二二二\『);printfC * *编号图书名作者名岀版社类别岀版时间}价格**\n9 ;printf("** %d %s %s %s %s %d %. 2fp->num, p->bname, p->wname, p->press, p->sort, p->time, p->price); printf C=\n〃);}}〃按图书名查询图书信息void bname_chaxun(struct book *head) {char a[50];int flag=0;struct book *p;printf (〃请选择您要查询的图书名:〃);gets (a);p=head;while(p!=NULL){if (strcmp(p->bname, a)==0){flag=l;break;p=p->next; }}辻(flag=O) {printff没有找到该图书名的图书!\n〃);}else {printf(〃你所查询的图书信息如下\n〃);printf C二二二\『);printf (〃桂编号图书名作者名出版社类别出版时间价格桂\n〃);while(p!=NULL){if(strcmp(p->bname, a)==0){printf("** %d %s %s %s %s %d %. 2f**\n,z, p->num, p->bname, p->wname, p->press, p->sort, p->time, p->price); }p=p->next;}printf C}===\n,z); }〃按作者名查询图书信息void wname_chaxun(struct book *head) { char a[50];int flag^O;struct book *p;printff请选择您要查询的图书作者名:〃); gets (a);p二head;while(p!=NULL){if (strcmp (p->wname, a) ==0) {flag=l;break;}p=p->next;}if(flag=0) {printff没有找到该图书名的图书!\n〃);}printf Celse {printfC你所查询的图书信息如下\n〃);printf C=\n〃);printfC **编号图书名作者名出版社类别出版时间价格while(p!=NULL){if (strcmp (p->wname, a) ==0) {printf("** %d %s %s %s %s %d %. 2fp->num, p->bname, p->wname, p->press, p->sort, p->time, p->price); flag=l;}p=p->next;}printf C=\n〃);}}〃按图书类别查询图书信息void sort_chaxun(struct book *head) {char a[50];int flag=0;struct book *p;printf C请选择您要查询的图书类别:〃);gets (a);p=head;while(p!=NULL){if(strcmp(p->sort, a)==0) {flag=l;break;}p二p->next;}辻(flag=O) {printff没有找到该图书名的图书!\n〃);}else {printf ("你所查询的图书信息如下\n〃);printf C=\『);printf (,z **编号图书名作者名出版社类别出版时间价格杯\n"); while(p!=NULL){if(strcmp(p->sort, a)==0) {printf C** %d %s %s %s %s %d %. 2f**\n,z, p->num, p->bname, p->wname, p->press, p->sort, p->time, p->price); flag=l;}p=p->next;}printf C=\『);}}〃按图书出版时间查询图书信息void time^chaxun(struct book *head) {int a,flag=0;struct book *p;printf r请选择您要查询的图书出版时间:〃);scanf("%d", &a);getchar ();p=head;while(p!=NULL){if (p->time==a) {flag=l;}break; }p=p->next;}if(flag=O) {printff没有找到该图书名的图书!\n〃);}else {printff你所查询的图书信息如下\n〃);printf(”=\n");printf (〃桂编号图书名作者名出版社类别出版时间价格while(p!=NULL){if(p->time==a){printf("** %d %s %s %s %s %d %. 2fp->num, p->bname, p->wname, p->press, p-〉sort, p->time, p-〉price);flag=l;}p二p-〉next;printf("}=\n");}}//修改图书信息void xiugai(struct book *head) {int a, b;char c;struct book *p;printfC请输入要修改的图书编号:〃);scanf&a);p=head;while(p!=NULL){if (p->num==a)break;p=p->next;}if(p二二NULL){printfC没有找到该编号的图书!\n〃); getchar ();}else {printf CW);printf r ** 1-编号2-图书名3-作者名printf C ** 4-出版社5-类别6-出版时间*水\n");printf C ** 7-价格8-修改全部0-放弃修改**\n");printf C============================\n");printf C请选择你要修改的信息编号:〃);scanf&b);getchar ();switch (b) {case 1:printf r请输入新编号:“);scanf&p->num);printf ("修改成功! \n");getchar ();break;case 2:printf r请输入新图书名:“);gets (p->bname);printf ("修改成功! \n");break;case 3:printff请输入新作者名:“);gets(p->wname);printf ("修改成功!\n"); break;case 4:printf r请输入新出版社:”);gets(p->press);printf ("修改成功! \n"); break;case 5:printf r请输入新类别:”);gets(p->sort);printf ("修改成功! \n"); break;case 6:printf r请输入新出版时间:“); scanf&p~>time);printf ("修改成功!\n"); getchar ();break;case 7:printf r请输入新价格:“); scanf ("%f", &p->price); printf ("修改成功! \n");getchar ();break;case 8:printf r请输入新图书编号:“);scanf&p->num);printf C请输入新图书名:“);scanf p->bname);getchar ();printf C请输入新作者名:“);scanf p->wname);getchar ();printf r请输入新出版社:”);scanfp->press);getchar ();printf r请输入新类别:“);scanf(〃%s: p->sort);getchar ();printf r请输入新出版时间:“);scanf&p->time);getchar ();printf r请输入新价格:〃);scanf ("%f", &p->price);getchar ();printf ("修改成功! \n");getchar ();break;case 0:break;default :printf C您的输入有误! \n");break;}printf C是否将修改后的信息保存到文件中?(y/n)\rT); scanf&c):getchar ();switch (c) {case ' n :break;case ,y‘ :fprint(head);printf ("保存成功!\n");getchar ();break;}}}〃图书排序void paixu(struct book *head) {int a;printf(”\ 〃 \\ > .----------------------------------------------------------------------- \n 丿, printf r ** 1-按图书编号排序2-按出版时间排序**\n");printf C ** 3-按图书价格排序4-按图书名排序**\n z/);printf C ** 5-按作者名排序0-取消排序操作材\n");printf (”___________________________________________________________________ \〃\ . \AX / f printf C请输入您选择的编号:〃);scanf("%d", &a);getchar ();switch(a){case 0:break;case 1:num_paixu(head); break;case 2:time_paixu(head);break;case 3:price_paixu(head);break;case 4:bname_paixu(head);break;case 5:wname_paixu(head);break;default:printf C您的输入有误! \n");break;}}〃按图书编号排序void num_paixu(struct book *head) {struct book *a[1000], *p, *pl, *temp; int i, k, index, n=0;for(p=head;p;p=p->next)n++;。
C#代码清单共1个项目,包含5个类。
项目:librarysystem类: Program.cs Readers.cs Manage.cs Menu.cs Publications.cs主类代码:namespace librarysystem{ ///<summary>///类名:Program///功能:项目主类///时间:2015-11-19///</summary>class Program{static void Main(string[] args){Menu meu = new Menu();meu.ShowMainMenu();Console.ReadLine();}}}出版物类代码:namespace librarysystem{ ///<summary>///类名:Publications///功能:馆藏出版物信息///时间:2015-11-19///</summary>class Publications{/*出版物编号*/private string PublicationISBN;public string PublicationIsbn{get{return PublicationISBN;}{PublicationISBN = value;}}/*出版物名称*/public string PublicationName;/*出版物作者或出版机构*/public string PublicationAuthor;/*出版物在架状态*/public bool PublicationStatus;/*出版物类型*/public string PublicationType;public Publications(){}public Publications(string PublicationISBN,string PublicationName,string PublicationAuthor,string PublicationType,bool PublicationStatus){this. PublicationISBN = PublicationISBN;this.PublicationName = PublicationName;this.PublicationAuthor = PublicationAuthor;this.PublicationType = PublicationType;this.PublicationStatus = PublicationStatus;}}}读者类代码:namespace librarysystem{ ///<summary>///类名:Readers///功能:已获取权限读者的信息///时间:2015-11-19///</summary>class Readers{private string ReaderID;public string ReaderId{get{return ReaderID;}setReaderID = value;}}public string ReaderName;public string ReaderSex;public string ReaderDepartment;public string ReaderMajor;public string[] BowPublication = new string[10]{"","","","","","","","","",""};public Readers(){}public Readers(string ReaderID, string ReaderName, string ReaderSex, string ReaderDepartment, string ReaderMajor){this.ReaderID = ReaderID;this.ReaderName = ReaderName;this.ReaderSex = ReaderSex;this.ReaderDepartment = ReaderDepartment;this.ReaderMajor = ReaderMajor;}}}管理类代码:namespace librarysystem{ ///<summary>///类名:Manage///功能:管理员执行图书管理操作///时间:2015-11-19///</summary>class Manage{public bool BorrowFlag = false;/*借阅操作成功标志*/public bool ReturnFlag = false;/*归还操作成功标志*/public Publications pub_search;/*保存查询到的出版物*/public Readers Red_valid;/*保存查询到的合法用户*//*声明馆藏出版物数组*/public Publications[] pubs=new Publications[200];/*声明注册读者数组*/public Readers[] reds=new Readers[30];/*实例化馆藏出版物对象*/public Publications pub0 = new Publications("000000","C#从入门到精通","明日科技","书籍",true);public Publications pub1 = new Publications("000001", "数值分析", "李清朗", "书籍", true);public Publications pub2 = new Publications("000002", "模式识别", "张学工", "书籍", true);public Publications pub3 = new Publications("000003", "中国国家地理", "地理科学院", "杂志", true);public Publications pub4 = new Publications("000004", "意林", "长春市文学艺术界联合会 ", "杂志", true);public Publications pub5 = new Publications("000005", "四川大学报", "四川大学", "报纸", true);public Publications pub6 = new Publications("000006", "经济学人", "伦敦经济学人报纸有限公司", "杂志", true);public Publications pub7 = new Publications("000007", "计算机网络", "谢希仁", "书籍", true);public Publications pub8 = new Publications("000008", "红楼梦", "曹雪芹", "书籍", true);public Publications pub9 = new Publications("000009", "新东方雅思培训课程", "俞敏洪", "音像制品", true);public Publications pub10 = new Publications("000010", "MATLAB实用教程", "张世杰", "音像制品", true);/*实例化已注册读者对象*/public Readers red0 = new Readers("20150000", "李华", "男", "电子信息学院", "电子与通信工程");public Readers red1 = new Readers("20150001", "王鹏", "男", "物理学院", "微电子学");public Readers red2 = new Readers("20150002", "张建豪", "男", "数学学院", "现代数学分析");public Readers red3 = new Readers("20150003", "陈莉", "女", "化学化工学院", "化学分析");public Readers red4 = new Readers("20150004", "吴娜", "女", "医学院", "口腔医学");public Readers red5 = new Readers("20150005", "宋雅茹", "女", "电子信息学院", "光学工程");/*初始化出版物数组*/public void PublicationsInitial(){pubs[0] = pub0;pubs[1] = pub1;pubs[2] = pub2;pubs[3] = pub3;pubs[4] = pub4;pubs[5] = pub5;pubs[6] = pub6;pubs[7] = pub7;pubs[8] = pub8;pubs[9] = pub9;pubs[10] = pub10;}/*初始化读者数组*/public void ReadersInitial(){reds[0] = red0;reds[1] = red1;reds[2] = red2;reds[3] = red3;reds[4] = red4;reds[5] = red5;}/*查询图书操作*/public bool SearchPublications(){string Pub_Name;bool SearchFlag = false;Pub_Name = Console.ReadLine();foreach (Publications pub in pubs){if (pub != null && pub.PublicationName == Pub_Name) {SearchFlag = true;pub_search = pub;}}return SearchFlag;}/*借阅图书操作*/public void Borrow(){string Red_Name;string Pub_Name;bool ReaderFlag = false;Red_Name = Console.ReadLine();foreach (Readers red in reds){if (red != null && red.ReaderName == Red_Name){ReaderFlag = true;Red_valid = red;}}if (ReaderFlag){Console.Write("请输入您需要借阅出版物的名称:");Pub_Name = Console.ReadLine();foreach (Publications pub in pubs){if (pub != null && pub.PublicationName == Pub_Name) {BorrowFlag = true;pub.PublicationStatus = false;AddToReders(pub.PublicationName, Red_valid);}}}else{Console.WriteLine("抱歉,您是非法读者,不能借阅图书"); }}/*归还图书操作*/public void Return(){string Red_Name;string Pub_Name;bool ReaderFlag = false;Red_Name = Console.ReadLine();foreach (Readers red in reds){if (red != null && red.ReaderName == Red_Name){ReaderFlag = true;Red_valid = red;}}if (ReaderFlag){Console.Write("请输入您需要归还出版物的名称:");Pub_Name = Console.ReadLine();foreach (Publications pub in pubs){if (pub != null && pub.PublicationName == Pub_Name){for (int i = 0; i < 10;i++ ){if (Red_valid.BowPublication[i] == Pub_Name){ReturnFlag = true;pub.PublicationStatus = true;RemoveFromReders(Pub_Name, Red_valid);}}}}}else{Console.WriteLine("抱歉,您是非法读者,无归还图书信息");}}/*添加图书到读者*/private void AddToReders(string PublicationName, Readers red){/*设置借阅上限为10本*/for (int i = 0; i < 10; i++){if (red != null && red.BowPublication[i]==""){red.BowPublication[i] = PublicationName;break;}}}/*从读者对象中移除图书*/private void RemoveFromReders(string PublicationName, Readers red) {/*设置借阅上限为10本*/for (int i = 0; i < 10; i++){if (red != null && red.BowPublication[i] == PublicationName) {red.BowPublication[i] = red.BowPublication[i+1];}}}/*新书入库操作*/public void AddPublications(Publications pub){for (int i = 11; i < 200; i++){if(pubs[i]==null){pubs[i] = pub;}}}/*添加新读者操作*/public void AddReaders(Readers red){for (int i = 6; i < 30; i++){if (reds[i] == null){reds[i] = red;}}}/*查询读者信息*/public void RedIndex(){string Red_Name;bool ReaderFlag = false;Red_Name = Console.ReadLine();foreach (Readers red in reds){if (red != null && red.ReaderName == Red_Name){ReaderFlag = true;Red_valid = red;}}if (!ReaderFlag){Console.WriteLine("抱歉,您是非法读者,无法查到您的借阅信息"); }}}}菜单类代码:namespace librarysystem{ ///<summary>///类名:Menu///功能:显示服务页面///时间:2015-11-19///</summary>class Menu{//创建一个具体的管理对象Manage mag = new Manage();//声明一个读者对象Readers red;//声明一个出版物对象Publications pub;public void ShowMainMenu(){mag.PublicationsInitial();mag.ReadersInitial();Console.WriteLine("欢迎使用图书管理系统V1.0");Console.WriteLine("-------------------------------------------------------------------");Console.WriteLine("1.查询图书");Console.WriteLine("2.借书服务");Console.WriteLine("3.还书服务");Console.WriteLine("4.新出版物入库");Console.WriteLine("5.录入新读者");Console.WriteLine("6.查询读者的借阅信息");Console.WriteLine("7.退出管理系统");Console.WriteLine("-------------------------------------------------------------------");bool flag;do{flag = false;Console.WriteLine("请选择:");string key = Console.ReadLine();switch (key){case"1":Console.Write("请输入需要查询图书的书名:");ShowPubInfo();break;case"2":Console.Write("请输入您的姓名:");mag.Borrow();ShowBorrowInfo();break;case"3":Console.Write("请输入您的姓名:");mag.Return();ShowReturnInfo();break;case"4":Console.WriteLine("请按照提示逐步输入需要入库出版物的信息……");ShowAddPublications();break;case"5":Console.WriteLine("请按照提示逐步输入新注册读者的信息……"); ShowAddReaders();break;case"6":Console.Write("请输入您的姓名: ");mag.RedIndex();ShowRedPubInfo(mag.Red_valid);break;case"7":flag = false;break;default:Console.WriteLine("无此业务,是否重新选择(y/n)?");string answer = Console.ReadLine();if (answer != "y"){flag = false;}else{flag = true;}break;}} while (flag);}/*显示查询到的出版物信息*/public void ShowPubInfo(){if (mag.SearchPublications()){Console.WriteLine("您要查询的出版物信息:");Console.WriteLine("-------------------------------------------------------------------");Console.WriteLine("编号: " + mag.pub_search.PublicationIsbn);Console.WriteLine("出版物名字: " + mag.pub_search.PublicationName);Console.WriteLine("出版物作者: " + mag.pub_search.PublicationAuthor);Console.WriteLine("出版物类型: " + mag.pub_search.PublicationType);if (mag.pub_search.PublicationStatus){Console.WriteLine("出版物状态:在架,可借");}else{Console.WriteLine("出版物状态:未在架,不可借");}Console.WriteLine("-------------------------------------------------------------------");Console.WriteLine("");Console.WriteLine("");Console.WriteLine("是否办理其他业务(y/n)?");string answer = Console.ReadLine();if (answer == "y"){ShowMainMenu();Console.WriteLine();}else{Console.WriteLine("结束");}}else{Console.WriteLine("抱歉,未找到该图书!");Console.WriteLine("是否办理其他业务(y/n)?");string answer = Console.ReadLine();if (answer == "y"){ShowMainMenu();Console.WriteLine();Console.WriteLine();}else{Console.WriteLine("结束");}}}/*显示借阅操作结果*/public void ShowBorrowInfo(){if (mag.BorrowFlag){Console.WriteLine("恭喜,借阅成功!");ShowRedPubInfo(mag.Red_valid);}else{Console.WriteLine("抱歉,借阅失败!");Console.WriteLine("是否办理其他业务(y/n)?");string answer = Console.ReadLine();if (answer == "y"){ShowMainMenu();}else{Console.WriteLine("结束");}}}/*显示归还操作结果*/public void ShowReturnInfo(){if (mag.ReturnFlag){Console.WriteLine("恭喜,归还成功!");ShowRedPubInfo(mag.Red_valid);}else{Console.WriteLine("抱歉,归还失败!");Console.WriteLine("是否办理其他业务(y/n)?");string answer = Console.ReadLine();if (answer == "y"){ShowMainMenu();}else{Console.WriteLine("结束");}}}public void ShowRedPubInfo(Readers red){Console.WriteLine("当前你的借阅信息如下:");Console.WriteLine("--------------------------------------------------------------------");Console.WriteLine("编号: " + red.ReaderId);Console.WriteLine("姓名: " + red.ReaderName);Console.WriteLine("性别: " + red.ReaderSex);Console.WriteLine("所在院系: " + red.ReaderDepartment);Console.WriteLine("主修专业: " + red.ReaderMajor);Console.Write("已借图书: ");for (int i = 0; i < red.BowPublication.Length-1; i++){if (red.BowPublication[i] != ""){Console.Write(" "+red.BowPublication[i]);}}Console.WriteLine("");Console.WriteLine("--------------------------------------------------------------------");Console.WriteLine("");Console.WriteLine("是否办理其他业务(y/n)?");string answer = Console.ReadLine();if (answer == "y"){ShowMainMenu();}else{Console.WriteLine("结束");}}/*显示新出版物入库的信息*/public void ShowAddPublications(){pub = new Publications();Console.Write("请输入出版物的编号: ");pub.PublicationIsbn=Console.ReadLine();Console.Write("请输入出版物的名称: ");pub.PublicationName = Console.ReadLine();Console.Write("请输入出版物的编者: ");pub.PublicationAuthor = Console.ReadLine();Console.Write("请输入出版物的类型: ");pub.PublicationType = Console.ReadLine();pub.PublicationStatus = true;mag.AddPublications(pub);Console.WriteLine("新出版物入库成功!");Console.WriteLine("是否办理其他业务(y/n)?");string answer = Console.ReadLine();if (answer == "y"){ShowMainMenu();Console.WriteLine();Console.WriteLine();}else{Console.WriteLine("结束");}}/*显示新读者注册的信息*/public void ShowAddReaders(){red = new Readers();Console.Write("请输入新注册读者的编号: "); red.ReaderId = Console.ReadLine();Console.Write("请输入新注册读者的姓名: "); red.ReaderName= Console.ReadLine();Console.Write("请输入新注册读者的性别: "); red.ReaderSex = Console.ReadLine();Console.Write("请输入新注册读者的院系: "); red.ReaderDepartment = Console.ReadLine();Console.Write("请输入新注册读者的专业: "); red.ReaderMajor = Console.ReadLine();for(int i=0;i<10;i++){red.BowPublication[i]="";}mag.AddReaders(red);Console.WriteLine("新读者注册成功!");Console.WriteLine("是否办理其他业务(y/n)?");string answer = Console.ReadLine();if (answer == "y"){ShowMainMenu();Console.WriteLine();Console.WriteLine();}else{Console.WriteLine("结束");}}}}。