Advertisement
Guest User

с.35

a guest
May 21st, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.26 KB | None | 0 0
  1. #include<string>
  2. #include<iostream>
  3. #include<algorithm>
  4. using namespace std;
  5. class Edition {
  6. public:
  7.     virtual void Show() = 0;
  8.     virtual void ChekSearch(string a) = 0;
  9. };
  10. class Book :public Edition {
  11. protected:
  12.     string Title, AuthorLastName, PublishingHouse;
  13.     int PublishingYear;
  14. public:
  15.     Book(string Title, string AuthorLastName) {
  16.         this->Title = Title;
  17.         this->AuthorLastName = AuthorLastName;
  18.     }
  19.     Book(string Title, string AuthorLastName, int PublishingYear) {
  20.         this->Title = Title;
  21.         this->AuthorLastName = AuthorLastName;
  22.         this->PublishingYear = PublishingYear;
  23.     }
  24.     Book(string Title, string AuthorLastName, string PublishingHouse, int PublishingYear) {
  25.         this->Title = Title;
  26.         this->AuthorLastName = AuthorLastName;
  27.         this->PublishingHouse = PublishingHouse;
  28.         this->PublishingYear = PublishingYear;
  29.     }
  30.     void Show() {
  31.         cout << "Название книги: " << Title << endl;
  32.         cout << "Автор: " << AuthorLastName << endl;
  33.         cout << "Издательство: " << PublishingHouse << endl;
  34.         cout << "Год выпуска: " << PublishingYear << endl;
  35.     }
  36.     void ChekSearch(string a) {
  37.         if (AuthorLastName == a) {
  38.             cout << "Найдено совпадение:" << endl;
  39.             Show();
  40.         }
  41.     }
  42. };
  43. class Article : public Book {
  44. protected:
  45.     string JournalName;
  46.     int Number;
  47. public:
  48.     Article(string Title, string AuthorLastName, string JournalName,int Number, int PublishingYear):Book(Title,AuthorLastName,PublishingYear) {
  49.         this->JournalName = JournalName;
  50.         this->Number = Number;
  51.     }
  52.     void Show() {
  53.         cout << "Название журнала: " << JournalName << endl;
  54.         cout << "Номер статьи: " << Number << endl;
  55.         cout << "Название статьи: " << Title << endl;
  56.         cout << "Автор: " << AuthorLastName << endl;
  57.         cout << "Год выпуска: " << PublishingYear << endl;
  58.     }
  59.     void ChekSearch(string a) {
  60.         if (AuthorLastName == a) {
  61.             cout << "Найдено совпадение:" << endl;
  62.             Show();
  63.         }
  64.     }
  65. };
  66. class OnlineResource : public Book {
  67. protected:
  68.     string Link, Annotation;
  69. public:
  70.     OnlineResource(string Title, string AuthorLastName, string Link, string Annotation):Book(Title,AuthorLastName) {
  71.         this->Link = Link;
  72.         this->Annotation = Annotation;
  73.     }
  74.     void Show() {
  75.         cout << "Название сайта: " << Title << endl;
  76.         cout << "Автор: " << AuthorLastName << endl;
  77.         cout << "Ссылка: " << Link << endl;
  78.         cout << "Аннотация: " << Annotation << endl;
  79.     }
  80.     void ChekSearch(string a) {
  81.         if (AuthorLastName == a) {
  82.             cout << "Найдено совпадение:" << endl;
  83.             Show();
  84.         }
  85.     }
  86. };
  87.  
  88. int main() {
  89.     setlocale(LC_ALL, "russian");
  90.     string b;
  91.     Edition *a[3];
  92.     a[0] = new Book("Учебник с++", "Ogneva", " Издательский Центр «Наука»", 2013);
  93.     a[1] = new Article("Абстрактные классы с++", "Слободчиков", "METANIT", 43, 2016);
  94.     a[2] = new OnlineResource("Cyberforum","Снежков","http://www.cyberforum.ru/","КиберФорум - форум программистов");
  95.     for (int i = 0; i < 3; i++) {
  96.         a[i]->Show();
  97.     }
  98.     cout << "Введите фамилию автора" << endl;
  99.     cin >> b;
  100.     for (int i = 0; i < 3; i++) {
  101.         a[i]->ChekSearch(b);
  102.     }
  103.     system("pause");
  104.     return 0;
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement