Question
This assignment consists of creating a hierarchy of classes for representing bibliographic references, as well as a simple data structure for storing them. The hierarchy
This assignment consists of creating a hierarchy of classes for representing bibliographic references, as well as a simple data structure for storing them. The hierarchy of references has one base class called Reference. All the References have a unique identifier, a title, an author, and a year of publication. The implementation of the classes must follow the object-oriented principles presented in the class.
Q1. Class Reference (15 marks)
Implement a class, called Reference, to represent the characteristics that are common to all the References. Namely,
1. All references must have a unique identifier (of type int).
2. All references have a title and author (both of type string or char*), as well a year of publication (of type int);
3. The class Reference has a default constructor that initializes data members to default values.
4. The class Reference has one regular constructor: Reference(int id, char* author, char* title, int year). Note that you can use string instead of char*. The constructor must initialize the id, author, title and year of publication of this reference using the given parameters.
5. int getId(): returns the unique identifier of this Reference;
6. char* getAuthor(); returns the author of this Reference;
7. char* getTitle(): returns the title of this Reference;
8. int getYear(): returns the year of publication of this Reference;
9. void print(): prints a string representation of this Reference consisting of the id number, reference title, author and year of publication;
Deliverable: reference.h, reference.cpp, and testreference.cpp (you are free to choose how many objects you want to create in order to test the class Reference. This applies also to subsequent questions).
Q2. Class Article (15 marks) Article is a specialized Reference that also has information about the journal where the article is published, start page, and end page. More precisely,
1. An Article is a derived class of Reference:
2. It also stores information about the journal (type string or char*), and the startPage and endPage (both of type int);
3. It has a default constructor that initializes data members, including the data members of the base class, to default values.
4. It has one regular constructor: Article (int id, char* author, char* title, int year, char* journal, int starPage, int endPage). It initializes all the characteristics that are common to all References, as well as the journal, and page range. You can assume that the parameters are valid;
5. char* getJournal(): returns the name of the journal;
6. int getStartPage(): returns the start page;
7. int getEndPage(): returns the end page;
8. It implements the member function int getNumberOfPages(), which returns the total number of pages (computed using starPage and endPage);
9. void print(): returns a string representation of objects of Article. This member function overrides the one defined in the class Reference.
Deliverable: article.h, article.cpp, and testarticle.cpp
In c++ please
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started