1 / 9

#include<iostream.h> #include<stdlib.h> #include<iomanip.h> #include<string.h> #include<fstre

#include<iostream.h> #include<stdlib.h> #include<iomanip.h> #include<string.h> #include<fstream.h> int i; void Libary();// 被调用函数. //---------------- 图书 Book 类 --------------------------- class book { private: int book_code,book_price;

chung
Download Presentation

#include<iostream.h> #include<stdlib.h> #include<iomanip.h> #include<string.h> #include<fstre

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. #include<iostream.h> #include<stdlib.h> #include<iomanip.h> #include<string.h> #include<fstream.h> int i; void Libary();//被调用函数

  2. //----------------图书Book类--------------------------- class book { private: int book_code,book_price; char book_name[30],book_author_name[30],book_publishing_date[30]; public: int get_book_code() //获取图书代码 { return book_code; } char get_book_name() //获取书名 { return book_name; } char get_book_author() //获取作者名 { return book_author_name; } char get_book_publishing_date() //获取出版日期 { return book_publishing_date; } int get_book_price() //获取图书价格 { return book_price; }

  3. void getbook() //接受图书的输入的信息 { cout<<"ADD NEW BOOK/PERIODICAL DETAILS"<<endl; book_code=i; cout<<Book code:"<<book_code<<endl; cout<<"Enter Book/Periodical name:"; cin>>book_name; cout<<"Enter Author Name:"; cin>>book_author_name; cout<<"Enter Publishing date:"; cin>>book_publishing_date; cout<<"Enter price:"; cin>>book_price; } void showbook() //输出图书有关信息 { cout<<"Book code:"<<book_code<<endl; cout<<"Book/Periodical name:"<<book_name<<endl; cout<<"Author name:"<<book_author_name<<endl; cout<<"Publishin date:"<<book_publishing_date<<endl; cout<<"Price:"<<book_price<<endl; } };

  4. //---------------------图书派生类issue----------- class issue:public book { // };

  5. //--------------------------期刊Periodical类----------------------//--------------------------期刊Periodical类---------------------- class Periodical { private: int periodical_code; char periodical_name[30],periodical_publisher_name[30],periodical_periosicity; public: int get_periodical_code() //获取期刊代码 { return periodical_code; } char get_periodical_name() //获取期刊名字 { return periodical_name; } char get_publisher_name() //获取出版商名字 { return periodical_publisher_name; } char get_periodicity() //获取期刊周期 { return periodicity; }

  6. void getperiodical() //获取期刊信息 { cout<<"ADD NEW PERIODICAL DETAILE"<<endl; periodical_code=i; cout<<"Periodical code:"; cin>>periodical_code; cout<<"Enter Book/Periodical name:"; cin>>periodical_name; cout<<"Enter Publisher name:"; cin>>periodical_publisher_name; cout<<"Enter Periodicity<F/M/S/Y>"; cin>>periodical_periosicity; } void showperiodical() //输出有关信息 { cout<<"Periodical code:"<<periodical_code<<endl; cout<<"Enter Book/Periodical name:"<<periodical_name<<endl; cout<<"Enter Publisher name:"<<periodical_publisher_name<<endl; cout<<"Enter Periodicity:"<<periodical_periosicity<<endl; } };

  7. //---------------主函数 --------------------- void main() { Libary(); // } //----------------被调用函数----------------------- void Libary() { END://使用goto语句的标号 Book p1; Periodical p2; Informations p3; Informations p5; int n;

  8. char b; fstream file_book; fstream file_periodical; fstream file_issue; cout<<" LIBRARY MANAGEMENT SYSTEM"<<endl; cout<<"1. Add new Book details"<<endl; cout<<"2. Add new periodical details"<<endl; cout<<"3. Record Issue / Return details"<<endl; cout<<"4. Delete old periodical Issue details"<<endl; cout<<"5. View Available Books / Periodicals"<<endl; cout<<"6. Exit"<<endl; cout<<"Enter choice:"; cin>>n; switch(n) { case 1: file_book.open("book.dat",ios::out|ios::app); file_All(A,"book.dat"); A.getbook(); file_book.write((char *)&A,sizeof(book)); file_book.close(); break; case 2: file_periodical.open("periodical.dat",ios::out | ios::app); file_All(B,"periodical.dat"); B.getperiodical(); file_periodical.write((char*)&B,sizeof(periodical)); file_periodical.close();

  9. break; case 3: file_issue.open("issue.dat",ios::out|ios::app); file_All(C,"issue.dat"); C. break; case 4: Delete_Booking(); //用指针实现 break; case 5: cout<<"VIEW AVAILABLE BOOKS/PERIODICAILS"<<enld; cout<<"View Books orPeriodicals?<B/P>:"; cin>>b; if(b=='B'||b=='b') { p1.showbook(); //查看图书 goto END; } else { p2.showperiodical() ; //查看期刊 goto END; } break; case 6: exit(-1); } }

More Related