图书管理系统的C#代码完整版
- 格式:docx
- 大小:28.00 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("结束"); }}}}。
#include <iostream> #include <iomanip>#include <string>#include <fstream>using namespace std;const int Reader=100;const int Maxb=100;const int Bor=5;class Student{private:int tag;int number;char name[10];int borbook[Bor];public:Student() { }char *getname(){return name;}int gettag(){return tag;}int getnumber(){return number;}void setname(char *na){strcpy(name,na);}void delbook(){tag=1;}void addStudent(int n,char *na) {tag=0;number=n;strcpy(name,na);for(int i=0;i<Bor;i++)borbook[i]=0;}void borrowbook(int bookid)//借书操作{for(int i=0;i<Bor;i++){if (borbook[i]==0){borbook[i]=bookid;return;}}}int retbook(int bookid)//还书操作{for(int i=0;i<Bor;i++){if(borbook[i]==bookid){borbook[i]=0;return 1;}}return 0;}void output()//读出读者信息{cout << setw(5) << number <<setw(10) << name<<"借书编号:["; for(int i=0;i<Bor;i++)if(borbook[i]!=0)cout << borbook[i] << "|";cout << "]"<<endl;}};class RData{private:int top; //读者记录指针Student read[Reader];public:RData() //构造函数,将Student.txt读到read[]中Student s;top=-1;fstream file("Student.txt",ios::in);//打开一个输入文件while (1){file.read((char *)&s,sizeof(s));if (!file)break;top++;read[top]=s;}file.close();}void clear(){top=-1;}int addStudent(int n,char *na)//查找是否存在{Student *p=equal(n);if (p==NULL)top++;read[top].addStudent(n,na);return 1;}return 0;}Student *equal(int Studentid)//按编号查找{for (int i=0;i<=top;i++)if (read[i].getnumber()==Studentid && read[i].gettag()==0){return &read[i];}return NULL;}void output(){for (int i=0;i<=top;i++)read[i].output();void Studentdata();//读者库维护~RData() //析构函数,将read[]写到Student.txt文件中{fstream file("Student.txt",ios::out);for (int i=0;i<=top;i++)if (read[i].gettag()==0)file.write((char *)&read[i],sizeof(read[i]));file.close();}};void RData::Studentdata(){char choice;char rname[20];int Studentid;Student *r;while (choice!='0'){cout<<"┏━━━━━━━━━━━━━┓\n";cout<<"┃读者维护┃\n";cout<<"┃━━━━━━━━━━━━━┃\n"; cout<<"┃1.新增┃\n";cout<<"┃━━━━━━━━━━━━━┃\n"; cout<<"┃2.更改┃\n";cout<<"┃━━━━━━━━━━━━━┃\n"; cout<<"┃3.删除┃\n";cout<<"┃━━━━━━━━━━━━━┃\n"; cout<<"┃4.查找┃\n";cout<<"┃━━━━━━━━━━━━━┃\n"; cout<<"┃5.显示┃\n";cout<<"┃━━━━━━━━━━━━━┃\n"; cout<<"┃6.全删┃\n";cout<<"┃━━━━━━━━━━━━━┃\n"; cout<<"┃0.退出┃\n";cout<<"┗━━━━━━━━━━━━━┛\n"; //cout<<cin >> choice;switch (choice){case '1':cout << "输入读者编号:";cin >> Studentid;cout << "输入读者姓名:";cin >> rname;addStudent (Studentid,rname); break;case '2':cout << "输入读者编号:";cin >> Studentid;r=equal(Studentid);if (r==NULL){cout << "该读者不存在"<<endl; break;}cout << "输入新的姓名:";cin >> rname;r->setname(rname);break;case '3':cout << "输入读者编号:";cin >> Studentid;r=equal(Studentid);if (r==NULL){cout <<"该读者不存在" << endl; break;}r->delbook();break;case '4':cout << "读入读者编号:";cin >> Studentid;r=equal(Studentid);if (r==NULL){cout <<"该读者不存在"<< endl; break;}r->output();break;case '5':output();break;case '6':clear();break;default:cout<<"退出:\n";system("cls");break; }}}class Book{private:int tag;int number;char name[20];int onshelf;public:Book(){}char *getname(){return name;}int getnumber(){return number;}int gettag(){return tag;}void setname(char na[]) {strcpy(name,na);}void delbook(){tag=1;}void addbook(int n,char *na) {tag=0;number=n;strcpy(name,na);onshelf=1;}int borrowbook()//借书操作{if (onshelf==1){onshelf=0;return 1;}return 0;}void retbook()//还书操作{onshelf=1;}void output()//输出图书{cout << setw(6) << number << setw(18) << name << setw(10) <<(onshelf==1? "在架":"已借") <<endl;}};class BDatabase{private:int top;Book book[Maxb]; //图书记录public:BDatabase()//构造函数,将book.txt读到book[]中{Book b;top=-1;fstream file("book.txt",ios::in);while (1){file.read((char *)&b,sizeof(b));if (!file) break;top++;book[top]=b;}file.close();}void clear(){top=-1;}int addbook(int n,char *na){Book *p=equal(n);if (NULL==p){top++;book[top].addbook(n,na);return 1;}return 0;}Book *equal(int bookid){for (int i=0;i<=top;i++)if (book[i].getnumber()==bookid &&book[i].gettag()==0) {return &book[i];}return NULL;}void bookdata();void output(){for (int i=0;i<=top;i++)if (book[i].gettag()==0)book[i].output();}~BDatabase()//析构函数,将book[]写到book.txt文件中{fstream file("book.txt",ios::out);for (int i=0;i<=top;i++)if (book[i].gettag()==0)file.write((char *)&book[i],sizeof(book[i]));file.close();}};void BDatabase::bookdata(){char choice;char bname[40];int bookid;Book *b;while (choice!='0'){cout<<"┏━━━━━━━━━━━━━┓\n"; cout<<"┃图书维护┃\n";cout<<"┃━━━━━━━━━━━━━┃\n"; cout<<"┃1.新增┃\n";cout<<"┃━━━━━━━━━━━━━┃\n"; cout<<"┃2.更改┃\n";cout<<"┃━━━━━━━━━━━━━┃\n"; cout<<"┃3.删除┃\n";cout<<"┃━━━━━━━━━━━━━┃\n"; cout<<"┃4.查找┃\n";cout<<"┃━━━━━━━━━━━━━┃\n"; cout<<"┃5.显示┃\n";cout<<"┃━━━━━━━━━━━━━┃\n"; cout<<"┃6.全删┃\n";cout<<"┃━━━━━━━━━━━━━┃\n"; cout<<"┃0.退出┃\n";cout<<"┗━━━━━━━━━━━━━┛\n"; cin >> choice;switch (choice){case '1':cout << "输入图书编号:"<<endl;cin >> bookid;cout << "输入图书书名:"<<endl;cin >> bname;addbook(bookid,bname);break;case '2':cout << "输入图书编号:"<<endl;cin >> bookid;b=equal(bookid);if (b==NULL){cout << "该图书不存在"<<endl;break;}cout << "输入新的书名:"<<endl;cin >> bname;b->setname(bname);break;case '3':cout <<"读入图书编号:"<<endl; cin >> bookid;b=equal(bookid);if (b==NULL){cout <<"该图书不存在" << endl; break;}b->delbook();break;case '4':cout << "读入图书编号:"<<endl; cin >> bookid;b=equal(bookid);if (b==NULL){cout <<"该图书不存在"<< endl;break;}b->output();break;case '5':output();break;case '6':clear();break;default:cout<<"退出\n"; system("cls"); break; }}}void main(){char choice;int bookid,Studentid;RData StudentDB;Student *r;BDatabase BookDB;Book *b;while(choice!='0'){cout<<"┏━━━━━━━━━━━━━┓\n"; cout<<"┃图书管理系统┃\n";cout<<"┃━━━━━━━━━━━━━┃\n"; cout<<"┃1.借书┃\n";cout<<"┃━━━━━━━━━━━━━┃\n"; cout<<"┃2.还书┃\n";cout<<"┃━━━━━━━━━━━━━┃\n"; cout<<"┃3.图书维护┃\n";cout<<"┃━━━━━━━━━━━━━┃\n"; cout<<"┃4.读者维护┃\n";cout<<"┃━━━━━━━━━━━━━┃\n"; cout<<"┃0.退出┃\n";cout<<"┗━━━━━━━━━━━━━┛\n"; cin >> choice;switch (choice){case '1': system("cls");cout <<"借书读者编号:";cin >>Studentid;cout <<"图书编号:";cin >>bookid;r=StudentDB.equal(Studentid);//按编号查找if (NULL==r){cout <<"不存在该读者,不能借书"<< endl; break;}b=BookDB.equal(bookid);if (b==NULL){cout <<"不存在该图书,不能借书"<< endl; break;}if (b->borrowbook()==0){cout << "该图书已借出,不能借书"<< endl; break;}r->borrowbook(b->getnumber());system("cls");case '2':system("cls");cout<<"还书\n读者编号:";cin >>Studentid;cout << "图书编号:";cin >>bookid;r=StudentDB.equal(Studentid);if (r==NULL){cout <<"不存在该读者,不能还书" << endl; break;}b=BookDB.equal(bookid);if (b==NULL){cout <<"不存在该图书,不能还书" <<endl; break;}b->retbook();r->retbook(b->getnumber());case '3':system("cls"); BookDB.bookdata(); break;case '4':system("cls"); StudentDB.Studentdata(); break;default:cout<<"退出\n"; }}}。
图书管理系统的设计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图书管理系统课程设计一、课程目标知识目标:1. 理解图书管理系统的基本概念和功能,掌握其在我国图书馆的应用现状。
2. 学会使用数据库管理图书信息,掌握基本的SQL查询语句。
3. 了解并掌握C语言编程在图书管理系统中的应用。
技能目标:1. 能够运用所学知识设计并实现一个简单的图书管理系统。
2. 提高问题分析能力,通过C语言编程解决图书管理中的实际问题。
3. 培养团队协作能力,通过分组讨论、共同开发完成课程项目。
情感态度价值观目标:1. 培养学生对图书管理工作的兴趣,提高对图书馆工作的认识。
2. 增强学生的信息素养,使其认识到信息管理在现代图书馆工作中的重要性。
3. 培养学生积极参与、乐于探究的学习态度,激发创新意识。
课程性质:本课程为实践性较强的课程,以C语言为基础,结合数据库知识,让学生在实际操作中掌握图书管理系统的设计与实现。
学生特点:学生具备一定的C语言基础和数据库知识,对实际应用有较高的兴趣,喜欢动手实践。
教学要求:注重理论与实践相结合,以学生为主体,鼓励学生主动参与、积极思考、动手实践。
通过课程学习,使学生能够独立设计并实现一个简单的图书管理系统,提高其编程能力和问题解决能力。
二、教学内容1. 理论知识:- 图书管理系统概述:介绍图书管理系统的基本概念、功能及在我国图书馆的应用现状。
- 数据库基础:回顾数据库的基本概念、数据模型、关系数据库及其设计方法。
- C语言编程:复习C语言基础知识,强调其在图书管理系统中的应用。
2. 实践操作:- 数据库设计:学习设计图书管理系统的数据库,包括表结构设计、数据完整性约束等。
- C语言编程实践:运用C语言编写图书管理系统的主要功能模块,如图书信息录入、查询、删除等。
- 项目开发:分组进行项目实践,培养学生团队协作能力,完成一个简单的图书管理系统。
3. 教学大纲:- 第一周:图书管理系统概述,复习C语言基础知识。
- 第二周:数据库基础,设计图书管理系统的数据库。
#include<stdio.h>/*输入输出函数*/#include<string.h>/*字符串操作函数*/#include<stdlib.h>/*数值转换函数*///#include<conio.h>/*控制台输入输出函数*/#define MAX 100/*宏定义,参数为形参*/struct book/*图书信息结构定义*/{intnum;/*图书编号*/char name[100];/*书名*/char author[100];/*作者名*/char fn[100];/*分类号*/char place[100];/*出版单位*/char day[100];/*出版时间*/float money;/*价格*/}book[MAX],temp;main()/*主函数*/{void Input();/*输入*/void Output();/*输出*/void Find();/*查找*/void Delete();/*删除*/void Change();/*修改*/void Paixu();/*排序*/int n;printf("\n");printf("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※\n");printf("※※\n");printf("※欢迎来河南工业大学图书信息管理系统※\n");printf("※※\n");printf("※※\n");printf("※★1.图书管理员系统★※\n");printf("※※\n");printf("※★2.读者系统★※\n");printf("※※\n");printf("※▲退出(输入其他数字)※\n");printf("※※\n");printf("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※\n");printf("请输入选择项(1-2):");scanf("%d",&n);printf("\n\n\n\n");if(n==1){int m;printf("请输入图书管理系统的密码:");scanf("%d",&m);if(m==1002){for(;;)/*省略"初始化"、"条件表达式"和"增量"*/{int s;printf("\n");printf("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※\n");printf("※※\n");printf("※欢迎来河南工业大学图书信息管理系统※\n");printf("※※\n");printf("※※\n");printf("※主菜单※\n");printf("※※\n");printf("※★1.图书信息录入★※\n");printf("※※\n");printf("※★2.图书信息浏览★※\n");printf("※※\n");printf("※★3.图书信息查询★※\n");printf("※※\n");printf("※★4.图书信息删除★※\n");printf("※※\n");printf("※★5.图书信息修改★※\n");printf("※※\n");printf("※★6.图书排序★※\n");printf("※※\n");printf("※★7.退出系统★※\n");printf("※※\n");printf("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※\n\n");printf("请输入选择项(1-7):");scanf("%d",&s);printf("\n\n\n\n");if(s>0&&s<8){switch(s){case 1:Input();break;case 2:Output();break;case 3:Find();break;case 4:Delete();break;case 5:Change();break;case 6:Paixu();break;case 7:printf("※※※※※※※※※※※※※※※※※※※※※※※※\n");printf("※※\n");printf("※谢谢使用! ※\n");printf("※再见! ※\n");printf("※※\n");printf("※※※※※※※※※※※※※※※※※※※※※※※※\n");exit(0);}}}}elseprintf("密码错误,请您重新进入系统\n");return 0;}else if(n==2){int t;printf("请输入读者密码:");scanf("%d",&t);if(t==.320){for(;;)/*省略"初始化"、"条件表达式"和"增量"*/{int h;printf("\n");printf("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※\n");printf("※※\n");printf("※欢迎来河南工业大学图书服务系统※\n");printf("※※\n");printf("※※\n");printf("※主菜单※\n");printf("※※\n");printf("※★1.图书信息浏览★※\n");printf("※※\n");printf("※★2.图书信息查询★※\n");printf("※※\n");printf("※★3.图书排序★※\n");printf("※※\n");printf("※★4.退出系统★※\n");printf("※※\n");printf("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※\n\n");printf("请输入选择项(1-4):");scanf("%d",&h);printf("\n\n\n\n");if(h>0&&h<5){switch(h){case 1:Output();break;case 2:Find();break;case 3:Paixu();break;case 4:printf("※※※※※※※※※※※※※※※※※※※※※※※※\n");printf("※※\n");printf("※谢谢使用! ※\n");printf("※再见! ※\n");printf("※※\n");printf("※※※※※※※※※※※※※※※※※※※※※※※※\n");exit(0);}}}}elseprintf("密码错误,请您重新进入系统\n");return 0;}else return 0;}void Find()/*查找*/{int i;intchoose,t;charans[100];do{printf("※※※※※※※※※※※※※※※※※※※※※※※※\n");printf("※※\n");printf("※ 1.按书名查找※\n");printf("※ 2.按作者名查找※\n");printf("※▲返回主菜单(输入其他数字)※\n");printf("※※\n");printf("※※※※※※※※※※※※※※※※※※※※※※※※\n");printf("输入选项代号:");scanf("%d",&choose);if(choose==1){printf("输入所查书名:\n");scanf("%s",ans);t=-1;if(choose==1){for(i=0;i<MAX;i++)if(strcmp(ans,book[i].name)==0){t=i;printf("%d %s %s %s %s %s %2f\n",book[t].num,book[t].name,book[t].author,bo ok[t].fn,book[t].place,book[t].day,book[t].money);}}if(t==-1)printf("不存在该信息\n");}else if(choose==2){printf("输入所查作者名:\n");scanf("%s",ans);t=-1;if(choose==2){for(i=0;i<MAX;i++)if(strcmp(ans,book[i].author)==0){t=i;printf("%d %s %s %s %s %s %2f\n",book[t].num,book[t].name,book[t].author,bo ok[t].fn,book[t].place,book[t].day,book[t].money);}}if(t==-1) printf("不存在该信息\n");}else return;}while(1);}void Output()/*输出*/{FILE *fp;int i;fp=fopen("book","rb");printf("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※\n");printf(" 图书列表\n");printf("-----------------------------------------------------------\n");printf("图书编号书名作者名分类号出版单位出版时间价格\n");printf("-----------------------------------------------------------\n");for(i=0;fread(&book[i],sizeof(struct book),1,fp)==1;i++){printf("%6d %8s %8s %8s %8s %8s %10.2f\n",book[i].num,book[i].name,book[i]. author,book[i].fn,book[i].place,book[i].day,book[i].money);}fclose(fp);}void Input()/*输入*/{FILE *fp;int n;fp=fopen("book","ab");/*建立一个新二进制文件*/for(n=0;n<MAX;n++){printf("n=%d 输入序号n(当输入n=-1时,返回),n=",n++);scanf("%d",&n);if(n==-1){fclose(fp);return;/*默认不返回值*/}else{printf("请输入图书编号书名作者名分类号出版单位出版时间价格\n");scanf("%d%s%s%s%s%s%f",&book[n].num,book[n].name,book[n].author,book[n ].fn,book[n].place,book[n].day,&book[n].money);fwrite(&book[n],sizeof(struct book),1,fp);/*写入文件*/}}fclose(fp);}void Delete()/*删除*/{FILE *fp;inti,flag,n,s,j;fp=fopen("book","rb+");rewind(fp);printf(" 图书列表\n");printf("-----------------------------------------------------------\n");printf("图书编号书名作者名分类号出版单位出版时间价格\n");printf("-----------------------------------------------------------\n");for(i=0;fread(&book[i],sizeof(struct book),1,fp)==1;i++){printf("%6d %8s %8s %8s %8s %8s %10.2f\n",book[i].num,book[i].name,book[i].auth or,book[i].fn,book[i].place,book[i].day,book[i].money);printf("\n");}n=i;printf("输入待删除图书编号:\n");scanf("%d",&s);for(i=0,flag=1;flag&&i<n;i++){if(s==book[i].num){for(j=i;j<n-1;j++){book[j].num=book[j+1].num;strcpy(book[j].name,book[j+1].name);strcpy(book[j].author,book[j+1].author);strcpy(book[j].fn,book[j+1].fn);strcpy(book[j].place,book[j+1].place);strcpy(book[j].day,book[j+1].day);book[j].money=book[j+1].money;}flag=0;}}if(!flag)n=n-1;elseprintf("没有此号\n");fp=fopen("book","wb");for(i=0;i<n;i++)fwrite(&book[i],sizeof(struct book),1,fp);fclose(fp);fp=fopen("book","r");printf(" 图书列表\n");printf("-----------------------------------------------------------\n");printf("图书编号书名作者名分类号出版单位出版时间价格\n");printf("-----------------------------------------------------------\n");for(i=0;i<n;i++){fread(&book[i],sizeof(struct book),1,fp);printf("%6d %8s %8s %8s %8s %8s %10.2f\n",book[i].num,book[i].name,book[i].auth or,book[i].fn,book[i].place,book[i].day,book[i].money);printf("\n");}fclose(fp);}void Change()/*修改*/{FILE *fp;inti,num,n;int flag=0;printf("请输入要修改的图书编号:");scanf("%d",&num);for(i=0;i<=MAX;i++)if(book[i].num==num){printf(" 图书列表\n");printf("-----------------------------------------------------------\n");printf("图书编号书名作者名分类号出版单位出版时间价格\n");printf("-----------------------------------------------------------\n");printf("%6d %8s %8s %8s %8s %8s %10.2f\n",book[i].num,book[i].name,book[i].auth or,book[i].fn,book[i].place,book[i].day,book[i].money);printf("-----------------------------------------------------------\n\n");n=i;flag=1;break;}if(flag==0){printf("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※\n");printf("※输入错误! ※\n");printf("※请返回! ※\n");printf("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※\n");return;}printf("\n\n\n");fp=fopen("book","rb+");fseek(fp,n*sizeof(struct book),0);printf("图书编号书名作者名分类号出版单位出版时间价格\n");scanf("%d%s%s%s%s%s%f",&book[n].num,book[n].name,book[n].author,book[n].fn, book[n].place,book[n].day,&book[n].money);fwrite(&book[i],sizeof(struct book),1,fp);fclose(fp);fp=fopen("book","rb");printf(" 图书列表\n");printf("-----------------------------------------------------------\n");printf("图书编号书名作者名分类号出版单位出版时间价格\n");printf("-----------------------------------------------------------\n");for(i=0;fread(&book[i],sizeof(struct book),1,fp)==1;i++){printf("%6d %8s %8s %8s %8s %8s %10.2f\n",book[i].num,book[i].name,book[i].auth or,book[i].fn,book[i].place,book[i].day,book[i].money);}printf("-----------------------------------------------------------\n\n");fclose(fp);}void Paixu()/*排序*/{FILE *fp;inti,max,s;fp=fopen("book","rb");for(s=0;fread(&book[s],sizeof(struct book),1,fp)==1;s++);for(i=0;i<s-i;i++){if(book[i].money>book[i+1].money){max=i;temp=book[i];book[i]=book[i+1];book[i+1]=temp;}}printf("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※\n");printf(" 图书列表\n");printf("-----------------------------------------------------------\n");printf("图书编号书名作者名分类号出版单位出版时间价格\n");for(i=0;i<s;i++){printf("%6d %8s %8s %8s %8s %8s %10.2f\n",book[i].num,book[i].name,book[i]. author,book[i].fn,book[i].place,book[i].day,book[i].money);}printf("-----------------------------------------------------------\n");getchar();}。
原创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(\。
图书管理系统/*图书数据由编号、书名、出版社、单价和图书状态(库存用0表示或借出用读者编号表示),读者数据由编号、姓名和电话号码构成。
实现功能包括:(1)添加图书的记录(2)图书管理(借书和还书)(3)对图书数据排序(按单价的降序)(4)删除图书记录(5)修改图书记录(6)添加读者记录(7)输出图书信息表和读者信息表*#include <stdio.h>#include <string.h>#include <stdlib.h>#include <windows.h>/*函数的声明*/void bookname();void writername();void booknumber();void press();void bookdate();void Bfind(); //查询主菜单void Bdevise(); //修改函数void Badd(); //添加函数void Bdelete(); //删除函数void Bdisplay(); //显示所以已保存的图书信息函数void Bclean(); //清除所有图书信息函数void lendbook(); // 借书函数void returnbook(); //还书函数void lendorreturnbook();//借书或还书主菜单函数void appealkey();//用户密码申诉函数void devisepeoplekey();//修改用户密码函数void accountapply(); //用户申请账户函数void addpeopleaccount(); //管理员之添加用户帐号函数void addmanageaccount(); //管理员之添加管理员账号函数void addaccount(); //管理员之账户添加主菜单函数void devisepeopleaccount();//管理员之修改用户账号函数void devisemanageaccount();//管理员之修改管理员帐号函数void deviseaccount();//管理员之修改账号主菜单函数void deletepeopleaccount();//管理员之删除用户账号函数void deletemanageaccount();//管理员之删除管理员账号函数void deleteaccount();//管理员之删除账号主菜单函数void displayallpeopleaccounts();//显示所有用户信息函数void displayallmanageaccounts();//显示所有管理员信息函数void displayallaccountsmessage();//显示所有账号信息主菜单函数void highaddpeopleaccount(); //高级管理员添加用户账户函数void highaddmanageaccount(); //高级管理员添加管理员账户函数void highaddaccount(); //高级管理员之添加账户主菜单函数void booksmanage();//图书操作主菜单函数void accountsmanage();//管理员账号操作主菜单函数void highaccountsmanage();//高级管理员账号操作主菜单函数void menu1(); //用户之查询主菜单void menu2(); //管理员之查询主菜单void menu3(); //高级管理员之查询主菜单/*定义书的类型*/struct book{int bookstock; //库存量char bookname[20]; //书名char bookwriter[20]; //作者char booknumber[20]; //书号char press[20]; //出版社char bookdate[20]; //出版日期char price[20]; //出版价格int turefalse; //判断图书是否被借阅}books[20];/*定义用户类型*/struct peopleaccount{char pname[20];char pkey[20];}peopleaccounts[20];/*定义管理员类型*/struct manageaccount{char mname[20];char mkey[20];}manageaccounts[20];/*定义借书卡类型*/struct card{char cardnumber[20]; //借书卡号和用户信息一起写入yonghu.txt文件中的}cards[20];/*定义文件指针变量*/FILE *fp1; //fp1打开用户信息文件FILE *fp2; //fp2打开管理员信息文件FILE *fp3; //fp3打开图书信息文件FILE *fp4; //打开借还书记录的文件FILE *fpa; //fpa是临时文件指针/*改变输出的字体颜色*/void color(const unsigned short color1){if(color1>=0&&color1<=15)SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color1);/*仅限改变0-15的颜色;如果在0-15那么实现他的颜色因为如果超过15后面的改变的是文本背景色。
c 图书管理系统课程设计一、教学目标本课程旨在让学生了解和掌握图书管理系统的基本原理和实际应用,培养学生运用计算机技术解决图书管理问题的能力。
具体目标如下:1.知识目标:使学生了解图书管理系统的起源、发展及其基本组成部分,掌握图书管理的基本流程和相关知识点,如图书分类、编号、借阅等。
2.技能目标:通过课程学习,学生能够熟练使用图书管理系统软件,进行图书信息的录入、查询、修改和删除等操作,具备一定的实际操作能力。
3.情感态度价值观目标:培养学生对图书管理工作的热爱和敬业精神,提高学生的人文素养,使学生认识到图书管理在现代社会的重要性。
二、教学内容本课程的教学内容主要包括以下几个部分:1.图书管理系统的基本概念:介绍图书管理系统的起源、发展及其在我国的应用现状。
2.图书管理基本流程:讲解图书的分类、编号、采购、登记、借阅等环节。
3.图书管理系统软件的使用:教授如何使用图书管理系统软件,进行图书信息的录入、查询、修改和删除等操作。
4.实际案例分析:分析典型图书管理案例,使学生能够将所学知识运用到实际工作中。
三、教学方法为了提高教学效果,本课程将采用多种教学方法相结合的方式进行授课:1.讲授法:教师讲解图书管理系统的相关概念、基本流程及软件使用方法。
2.案例分析法:分析典型图书管理案例,引导学生运用所学知识解决实际问题。
3.实验法:学生进行上机操作,使学生熟练掌握图书管理系统软件的使用。
4.讨论法:鼓励学生就图书管理中的实际问题进行讨论,培养学生的团队协作能力。
四、教学资源为了支持本课程的教学,我们将准备以下教学资源:1.教材:选用权威、实用的教材,为学生提供系统的学习资料。
2.参考书:提供相关领域的参考书籍,丰富学生的知识视野。
3.多媒体资料:制作精美的PPT课件,提高课堂教学效果。
4.实验设备:配置充足的计算机设备,保证学生上机操作的需求。
5.网络资源:利用校园网络,为学生提供丰富的在线学习资源。
五、教学评估本课程的教学评估将采用多元化方式进行,全面、客观地评价学生的学习成果。
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课程设计一、课程目标知识目标:1. 学生能理解图书管理系统的基本概念,掌握C语言在系统开发中的应用。
2. 学生能掌握结构体、文件操作、指针等C语言核心知识,并运用到图书管理系统中。
3. 学生了解并掌握图书管理系统的功能模块,如图书入库、查询、借阅等。
技能目标:1. 学生能运用所学知识,设计并实现一个简单的图书管理系统。
2. 学生能通过C语言编程,完成图书管理系统中的各个功能模块。
3. 学生能运用调试工具,对程序进行调试和优化,提高程序的性能。
情感态度价值观目标:1. 培养学生主动探索、积极实践的精神,提高解决问题的能力。
2. 培养学生的团队协作意识,学会与他人共同完成项目任务。
3. 培养学生关注实际应用,将所学知识运用到实际项目中,提高学习兴趣。
分析课程性质、学生特点和教学要求:本课程为C语言课程设计,旨在让学生将所学知识运用到实际项目中。
学生已具备一定的C语言基础,但实际操作能力有待提高。
教学要求注重实践,强调学生动手能力,培养解决实际问题的能力。
课程目标分解:1. 知识目标:通过讲解和案例分析,使学生掌握图书管理系统的基本概念和C语言应用。
2. 技能目标:通过项目实践,让学生独立完成图书管理系统的设计与实现,提高编程能力。
3. 情感态度价值观目标:在教学过程中,注重培养学生主动探索、团队协作和关注实际应用的意识。
二、教学内容1. C语言基础知识回顾:结构体、文件操作、指针等核心概念及其应用。
2. 图书管理系统需求分析:介绍图书管理系统的功能需求,如图书入库、查询、借阅等。
3. 系统设计:- 系统架构设计:模块划分,功能描述。
- 数据结构设计:定义图书信息、用户信息等数据结构。
4. 功能模块实现:- 图书入库模块:实现图书信息的添加、修改和删除。
- 查询模块:实现按书名、作者、分类等条件的查询功能。
- 借阅模块:实现图书借阅、归还、续借等功能。
- 用户管理模块:实现用户注册、登录、权限设置等功能。
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("结束"); }}}}。