Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<string>
- #include<iostream>
- #include<algorithm>
- using namespace std;
- class Edition {
- public:
- virtual void Show() = 0;
- virtual void ChekSearch(string a) = 0;
- };
- class Book :public Edition {
- protected:
- string Title, AuthorLastName, PublishingHouse;
- int PublishingYear;
- public:
- Book(string Title, string AuthorLastName) {
- this->Title = Title;
- this->AuthorLastName = AuthorLastName;
- }
- Book(string Title, string AuthorLastName, int PublishingYear) {
- this->Title = Title;
- this->AuthorLastName = AuthorLastName;
- this->PublishingYear = PublishingYear;
- }
- Book(string Title, string AuthorLastName, string PublishingHouse, int PublishingYear) {
- this->Title = Title;
- this->AuthorLastName = AuthorLastName;
- this->PublishingHouse = PublishingHouse;
- this->PublishingYear = PublishingYear;
- }
- void Show() {
- cout << "Название книги: " << Title << endl;
- cout << "Автор: " << AuthorLastName << endl;
- cout << "Издательство: " << PublishingHouse << endl;
- cout << "Год выпуска: " << PublishingYear << endl;
- }
- void ChekSearch(string a) {
- if (AuthorLastName == a) {
- cout << "Найдено совпадение:" << endl;
- Show();
- }
- }
- };
- class Article : public Book {
- protected:
- string JournalName;
- int Number;
- public:
- Article(string Title, string AuthorLastName, string JournalName,int Number, int PublishingYear):Book(Title,AuthorLastName,PublishingYear) {
- this->JournalName = JournalName;
- this->Number = Number;
- }
- void Show() {
- cout << "Название журнала: " << JournalName << endl;
- cout << "Номер статьи: " << Number << endl;
- cout << "Название статьи: " << Title << endl;
- cout << "Автор: " << AuthorLastName << endl;
- cout << "Год выпуска: " << PublishingYear << endl;
- }
- void ChekSearch(string a) {
- if (AuthorLastName == a) {
- cout << "Найдено совпадение:" << endl;
- Show();
- }
- }
- };
- class OnlineResource : public Book {
- protected:
- string Link, Annotation;
- public:
- OnlineResource(string Title, string AuthorLastName, string Link, string Annotation):Book(Title,AuthorLastName) {
- this->Link = Link;
- this->Annotation = Annotation;
- }
- void Show() {
- cout << "Название сайта: " << Title << endl;
- cout << "Автор: " << AuthorLastName << endl;
- cout << "Ссылка: " << Link << endl;
- cout << "Аннотация: " << Annotation << endl;
- }
- void ChekSearch(string a) {
- if (AuthorLastName == a) {
- cout << "Найдено совпадение:" << endl;
- Show();
- }
- }
- };
- int main() {
- setlocale(LC_ALL, "russian");
- string b;
- Edition *a[3];
- a[0] = new Book("Учебник с++", "Ogneva", " Издательский Центр «Наука»", 2013);
- a[1] = new Article("Абстрактные классы с++", "Слободчиков", "METANIT", 43, 2016);
- a[2] = new OnlineResource("Cyberforum","Снежков","http://www.cyberforum.ru/","КиберФорум - форум программистов");
- for (int i = 0; i < 3; i++) {
- a[i]->Show();
- }
- cout << "Введите фамилию автора" << endl;
- cin >> b;
- for (int i = 0; i < 3; i++) {
- a[i]->ChekSearch(b);
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement