Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <string>
- using namespace std;
- class Edition
- {
- protected:
- string name, fam;
- public:
- string getName() {
- return name;
- }
- string getFam() {
- return fam;
- }
- void setName(string name) {
- this->name = name;
- }
- void setFam(string fam) {
- this->fam = fam;
- }
- virtual void info() {
- cout <<"Name:" << name << "Author:" << " " << fam;
- }
- };
- class Book : public Edition
- {
- private:
- string izdat;
- int year;
- public:
- Book(string name, string fam, string izdat, int year) {
- setName(name);
- setFam(fam);
- setIzdat(izdat);
- setYear(year);
- }
- void setIzdat(string izdat) {
- this->izdat = izdat;
- }
- void setYear(int year) {
- this->year = year;
- }
- void info() {
- cout << "Name:" << getName() << " " << "Author:" << getFam() << " " << "Publishing:" << izdat << " " << "Year of publishing:" << year << endl;
- }
- };
- class Article : public Edition
- {
- private:
- string magazine;
- int num, year;
- public:
- Article(string name, string fam, string magazine, int num, int year) {
- setName(name);
- setFam(fam);
- setmagazine(magazine);
- setnum(num);
- setyear(year);
- }
- void setmagazine(string magazine) {
- this->magazine = magazine;
- }
- void setnum(int num) {
- this->num = num;
- }
- void setyear(int year) {
- this->year = year;
- }
- void info() {
- cout << "Name:" << getName() << " " << "Author:" << getFam() << " " << "Magazine:" << magazine << " " << "Numeric of Magazine:" << num << " " << "Year of publishing:" << year << endl;
- }
- };
- class OnlineResource : public Edition
- {
- private:
- string link, annotation;
- public:
- OnlineResource(string name, string fam, string link, string annotation) {
- setName(name);
- setFam(fam);
- setlink(link);
- setannotation(annotation);
- }
- void setlink(string link) {
- this->link = link;
- }
- void setannotation(string annotation) {
- this->annotation = annotation;
- }
- void info() {
- cout << "Name:" << getName() << " " << "Author:" << getFam() << " " << "Link:" << link << " " << "Annotation:" << annotation << endl;
- }
- };
- void find_fam(Edition** a, string fam, int n) {
- for (int i = 0; i < n; i++) {
- if (a[i]->getFam() == fam) {
- a[i]->info();
- cout << endl;
- }
- }
- }
- int main() {
- int n = 12;
- Edition** base = new Edition * [n];
- base[0] = new Book("Harry Potter and the Sorcerer's Stone", "Rowling", "Scholastic", 2012);
- base[1] = new Book("Hunger Games", "Collins", "Mavink", 2013);
- base[2] = new Book("Play to live: War", "DmitriRus", "eksmo", 2019);
- base[3] = new Book("The Witcher: the last wish", "Sapkowski", "mavink", 2020);
- base[4] = new Article("Harry Potter and the Half-Blood Prince", "Rowling", "Good Reading", 32, 2014);
- base[5] = new Article("Hunger Games: Cathing Fire", "Collins", "Good Reading", 14, 2012);
- base[6] = new Article("Play to live: breakdown", "DmitriRus", "Good Reading", 55, 2017);
- base[7] = new Article("The Witcher: sword of destiny", "Sapkowski", "Good Reading", 23, 2015);
- base[8] = new OnlineResource("Harry Potter and the Chamber of Secrets", "Rowling", "www.potter.com", "fantastic");
- base[9] = new OnlineResource("Hunger Games: Mockingjay", "Collins", "www.hungergames.com", "thriller");
- base[10] = new OnlineResource("Play to live: clan", "DmitriRus", "www.playtolive.com", "litrpg");
- base[11] = new OnlineResource("The Witcher: baptism of fire", "Sapkowski", "www.thewitcher.com", "fantastic");
- for (int i = 0; i < n; i++) {
- base[i]->info();
- cout << endl;
- }
- string fami;
- cin >> fami;
- find_fam(base, fami, n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement