Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3. using namespace std;
  4. class Library
  5. {
  6. private:
  7. int id;
  8. string author;
  9. string date;
  10. string title;
  11. string department;
  12. public:
  13. void set_id(int _id);
  14. void set_author(string _author);
  15. void set_date(string _date);
  16. void set_title(string _title);
  17. void set_department(string _department);
  18. int get_id(void);
  19. string get_author(void);
  20. string get_date(void);
  21. string get_title(void);
  22. string get_department(void);
  23. };
  24. void Library::set_id(int _id)
  25. {
  26. id = _id;
  27. }
  28. int Library::get_id(void)
  29. {
  30. return id;
  31. }
  32. void Library::set_author(string _author)
  33. {
  34. author = _author;
  35. }
  36. string Library::get_author(void)
  37. {
  38. return author;
  39. }
  40. void Library::set_title(string _title)
  41. {
  42. title = _title;
  43. }
  44. string Library::get_title(void)
  45. {
  46. return title;
  47. }
  48. void Library::set_department(string _department)
  49. {
  50. department = _department;
  51. }
  52. string Library::get_department(void)
  53. {
  54. return department;
  55. }
  56. void Library::set_date(string _date)
  57. {
  58. date = _date;
  59. }
  60. string Library::get_date(void)
  61. {
  62. return date;
  63. }
  64. int main()
  65. {
  66. cout<<"Enter how many books you want to store: ";
  67. int n;
  68. cin>>n;
  69. Library library[n];
  70. string aut;
  71. int idd;
  72. string dat;
  73. string titl;
  74. string dep;
  75.  
  76. for (int i=0; i<n; i++)
  77. {
  78. cout<<"Enter author"<<endl;
  79. cin>>aut;
  80. library[i].set_author(aut);
  81. cout<<"Enter id"<<endl;
  82. cin>>idd;
  83. library[i].set_id(idd);
  84. cout<<"Enter title"<<endl;
  85. cin>>titl;
  86. library[i].set_title(titl);
  87. cout<<"Enter date"<<endl;
  88. cin>>dat;
  89. library[i].set_date(dat);
  90. cout<<"Enter department"<<endl;
  91. cin>>dep;
  92. library[i].set_department(dep);
  93.  
  94. }
  95. int p=1;
  96. while (p==1)
  97. {
  98. cout<<"Enter a number from 1 to "<<n<<" to list information about the book "<<endl;
  99. int k;
  100. cin>>k;
  101. cout<<library[k].get_author()<<endl;
  102. cout<<library[k].get_id()<<endl;
  103. cout<<library[k].get_title()<<endl;
  104. cout<<library[k].get_date()<<endl;
  105. cout<<library[k].get_department()<<endl;
  106.  
  107.  
  108.  
  109. cout<<"Enter 1 to continue or 0 to terminate: ";
  110. cin>>p;
  111. }
  112.  
  113.  
  114. return 0;
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement