Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- using namespace std;
- class Library
- {
- private:
- int id;
- string author;
- string date;
- string title;
- string department;
- public:
- void set_id(int _id);
- void set_author(string _author);
- void set_date(string _date);
- void set_title(string _title);
- void set_department(string _department);
- int get_id(void);
- string get_author(void);
- string get_date(void);
- string get_title(void);
- string get_department(void);
- };
- void Library::set_id(int _id)
- {
- id = _id;
- }
- int Library::get_id(void)
- {
- return id;
- }
- void Library::set_author(string _author)
- {
- author = _author;
- }
- string Library::get_author(void)
- {
- return author;
- }
- void Library::set_title(string _title)
- {
- title = _title;
- }
- string Library::get_title(void)
- {
- return title;
- }
- void Library::set_department(string _department)
- {
- department = _department;
- }
- string Library::get_department(void)
- {
- return department;
- }
- void Library::set_date(string _date)
- {
- date = _date;
- }
- string Library::get_date(void)
- {
- return date;
- }
- int main()
- {
- cout<<"Enter how many books you want to store: ";
- int n;
- cin>>n;
- Library library[n];
- string aut;
- int idd;
- string dat;
- string titl;
- string dep;
- for (int i=0; i<n; i++)
- {
- cout<<"Enter author"<<endl;
- cin>>aut;
- library[i].set_author(aut);
- cout<<"Enter id"<<endl;
- cin>>idd;
- library[i].set_id(idd);
- cout<<"Enter title"<<endl;
- cin>>titl;
- library[i].set_title(titl);
- cout<<"Enter date"<<endl;
- cin>>dat;
- library[i].set_date(dat);
- cout<<"Enter department"<<endl;
- cin>>dep;
- library[i].set_department(dep);
- }
- int p=1;
- while (p==1)
- {
- cout<<"Enter a number from 1 to "<<n<<" to list information about the book "<<endl;
- int k;
- cin>>k;
- cout<<library[k].get_author()<<endl;
- cout<<library[k].get_id()<<endl;
- cout<<library[k].get_title()<<endl;
- cout<<library[k].get_date()<<endl;
- cout<<library[k].get_department()<<endl;
- cout<<"Enter 1 to continue or 0 to terminate: ";
- cin>>p;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement