Curriculum Design-Library information Management system

Source: Internet
Author: User

Introduction: Curriculum Design-Bank savings system--"here

Library information Management system includes: Login number, title, author name, classification number, publishing unit, publication time, Price and so on. Try to design a library information management system, so that it can provide the following functions:

(1) The system works in menu mode
(2) Library information entry function (student information file saving)---input
(3) Book information browsing function---output
(4) Query, sorting function
Query by login number
Search by Title

(5) Deletion and modification of book information

Source:

Here is the source code:

Book.h:

#ifndef book_h_included#define book_h_included#include<fstream> #include <iostream> #include <cstdlib > #include <string>using namespace std;class book//Books class {private:string number;//landing number string name;//title Stri  ng author;//Author string snumber;//class number string office;//Publication unit string time;//publication time string money;//price public:string    Get_number () {return number;}    String Get_name () {return name;}    String Get_author () {return author;}    String Get_snumber () {return snumber;}    String Get_office () {return office;}    String Get_time () {return time;}    String Get_money () {return money;}    void Set_number (String num) {number=num;}    void Set_name (string n) {name=n;}    void Set_author (String a) {author=a;}    void Set_snumber (String sn) {snumber=sn;}    void Set_office (String o) {office=o;}    void Set_time (String t) {time=t;}    void Set_money (string m) {money=m;} void Setbook (String num,string n,string a,string sn,string o,string t,string m);}; #endif//book_h_included 

Menu.h:

#ifndef menu_h_included#define menu_h_included#include<fstream> #include <iostream> #include <cstdlib > #include <string>using namespace std;class menu{public: Book    *book=new book[5000];    Menu ();    ~menu ();    int num;    void ShowMenu ();    int Name_search (string);//Eucalyptus name find    int num_search (string);//Find    void Searchbook (int) by login number;//find book    void Showinfo (int);//display book Information    void Showchange ();//Display Information change menu    void ShowAll ();//display all information    int openfile (void);// Open file    void SaveFile ();//save file    void Addinfo ();//Add book Information    void Changeinfo ();//modify book information}; #endif//Menu_h_ INCLUDED

Book.cpp:

#include <fstream> #include <iostream> #include <cstdlib> #include <string> #include "book.h" Using namespace Std;void book::setbook (string num,string n,string a,string sn,string o,string t,string m) {    number= num;    Name=n;    Author=a;    SNUMBER=SN;    office=o;    time=t;    Money=m;}

Menu.cpp:

#include <fstream> #include <iostream> #include <cstdlib> #include <string> #include "book.h" # Include "Menu.h" using namespace std;    Menu::menu () {num=0;    String number,n,a,sn,o,t,m;    Ifstream infile ("Bookinfo.dat", ios::in); if (!infile) {cout<< "Open file failed!        ";    Exit (1); } while (infile>>number>>n>>a>>sn>>o>>t>>m) {Book[num].setbook (num        BER,N,A,SN,O,T,M);    num++;    } infile.close ();    cout<<num<<endl; File read End}menu::~menu () {delete []book;}    void Menu::savefile () {int i;    Ofstream outfile ("Bookinfo.dat", ios::out); if (!outfile) {cout<< "Open file failed!        ";    Exit (1); } for (i=0; i<num; i++) {outfile<<book[i].get_number () << "" <<book[i].get_name () << "" <<book[i].get_author () << "" <<book[i].get_snumber () << "" <<book[i].get_office () << "" <<book[i].get_time () << "" <<book[i].get_money () <<endl; } outfile.close ();} void Menu::showmenu () {/*for (int i=0; i<num; i++) {cout<<book[i].get_number () <<book[i].get_n    Ame () <<endl;    }*/cout<< "+-------------------+" <<endl;    cout<< "Library Information Management system" <<endl;    cout<< "+-------------------+" <<endl;    cout<< "1, Search by login number" <<endl;    cout<< "2, Find by title" <<endl;    cout<< "3, Book information browse" <<endl;    cout<< "4, Book Information entry" <<endl;    cout<< "5, modify book information" <<endl; cout<< "Please select function (enter 0 exit):";}    void Menu::showchange (void) {cout<< "+-------------------+" <<endl;    cout<< "1, Landing No." <<endl;    cout<< "2, title" <<endl;    cout<< "3, author name" <<endl;    cout<< "4, Class No." <<endl;    cout<< "5, publishing unit" <<endl;    cout<< "6, Publication Time" <<endl;    cout<< "7, Price" <<endl;    cout<< "+-------------------+" <<endl; cout<< "Please enter the options you want to modify(1-7): ";}    int Menu::name_search (string key)//Search by title {int i;    for (i=0; i<num; i++) {if (Key==book[i].get_name ()) return i; } return i;}    int Menu::num_search (string key)//Find {int i=-1 by login number;    for (i=0; i<num; i++) {if (Key==book[i].get_number ()) return i; } return i;}    void Menu::searchbook (int)//Find book information {string numkey,namekey;    int i;            while (1) {if (way==1) {cout<< "Please enter the book login number:";            cin>>numkey;            I=num_search (Numkey); if (i==-1) {cout<< "no this book information!"                <<endl;            Continue                } else {showinfo (i);                System ("PAUSE");            Break            }} else if (way==2) {cout<< "Please enter the title:";            cin>>namekey;            I=name_search (Namekey); if (i==-1) {cout<< "No information on this book!                "<<endl;            Continue                } else {showinfo (i);                System ("PAUSE");            Break }}}}void menu::showinfo (int i) {cout<<book[i].get_number () << "" <<book[i].get_name () &LT;&L t; " "<<book[i].get_author () <<" "<<book[i].get_snumber () <<" "<<book[i].get_office () < < "<<book[i].get_time () <<" "<<book[i].get_money () <<endl;}    void Menu::showall () {int i;    cout<< "book Information:" <<endl<<cout<< "in turn, the book's Landing number, title, author name, classification number, publishing unit, publication time, Price:" <<endl;    for (i=0; i<num; i++) {showinfo (i); } System ("PAUSE");}    void Menu::addinfo () {int add,addsum,tem;    Tem=num;    String numb,n,a,sn,o,t,m;    cout<< "Please enter the number of input:";    cin>>addsum;    cout<< "Please enter the book login number, title, author name, classification number, publishing unit, publication time, price" <<endl; cout<< "For example: 201501" In this complex world "Han Han 201 Zhejiang press 2014-06-01" <<endl    Open File Ofstream outfile ("Bookinfo.dat", Ios::app); if (!outfile) {cout<< "Open file failed!        ";    Exit (1);    } tem+=addsum; for (Add=tem; add< (Addsum+tem); add++) {Cin>>numb>>n>>a>>sn>>o>>t>&gt        ; m; outfile<<numb<< "<<n<<" "<<" "<<a<<" "<<sn<<" "<<a<    < "<<t<<" <<m<<endl;    } Num=addsum+tem;    Outfile.close (); cout<< "Write End! A total of "<<num-1<<" records are written for "<<addsum<<" records.    "<<endl;    System ("PAUSE");    File Write end}void menu::changeinfo () {int i;    String numkey,numb,n,a,sn,o,t,m;    int cut;    cout<< "Please enter the login number of the book to be modified:";    cin>>numkey;    I=num_search (Numkey);    cout<< "You are modifying" ";    Showinfo (i);    cout<< "" Information <<endl;    Showchange ();    cin>>cut;    cout<< "Please enter the modified content:";  while (1) {if (cut==1) {cin>>numb;          Book[i].set_number (numb);            } else if (cut==2) {cin>>n;        Book[i].set_name (n);            } else if (cut==3) {cin>>a;        Book[i].set_author (a);            } else if (cut==4) {cin>>sn;        Book[i].set_snumber (SN);            } else if (cut==5) {cin>>o;        Book[i].set_office (o);            } else if (cut==6) {cin>>t;        Book[i].set_time (t);            } else if (cut==7) {cin>>m;        Book[i].set_money (m); } else {cout<< "input error, please re-enter.            "<<endl;        Continue        } savefile (); cout<< "modified successfully!        "<<endl;        System ("PAUSE");    Break }}

Main.cpp:

#include <fstream> #include <iostream> #include <cstdlib> #include <string> #include "book.h" # Include "Menu.h" using namespace Std;int Main () {    int choice;    Menu m;    while (1)    {        system ("CLS");        M.showmenu ();//Display Start menu        cin>>choice;        Switch (choice)        {case        0:cout<< "Thanks for using the book Management system! "; exit (1);        Case 1:m.searchbook (1);        Case 2:m.searchbook (2);        Case 3:m.showall ();        Case 4:m.addinfo ();        Case 5:m.changeinfo ();        Default:            cout<< "input error, please re-enter. ";        }    }    return 0;}

: Software run:







Book Database information:



@ Mayuko

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Curriculum Design-Library information Management system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.