Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help creating object files for the following classes. I am a beginner and need to understand : #ifndef AUTHOR _ NARRATOR _ H

I need help creating object files for the following classes. I am a beginner and need to understand : #ifndef AUTHOR_NARRATOR_H
#define AUTHOR_NARRATOR_H
#include
#include
#include "Book.h"
class AuthorNarrator {
private:
std::string name;
std::vector authoredBooks;
public:
// Constructor
AuthorNarrator(const std::string& name);//initializes an author/narrator with a given name
// Destructor
~AuthorNarrator();//cleans up memory for books
// Getters
std::string getName() const;//returns the name of the author/narrator
std::vector getAuthoredBooks() const;//returns the lists of books by the author/narrato
// Setters
void setName(const std::string& name);//sets the name of the author/narrator
// Other methods
void addAuthoredBook(Book* book);//adds a book by author narrator
void removeAuthoredBook(Book* book);//removes a book by author/narrator
void listAuthoredBooks() const;//lists all books by author/narrator
};
#endif // AUTHOR_NARRATOR_H.............................................#ifndef BOOK_H
#define BOOK_H
#include
#include
class AuthorNarrator; // Forward declaration
class Book {
private:
std::string title;
std::vector authors;
int publicationYear;
std::string genre;
bool isAvailable;
public:
// Constructor
Book(const std::string& title, int publicationYear, const std::string& genre);
// Destructor
~Book();
// Getters
std::string getTitle() const;
std::vector getAuthors() const;
int getPublicationYear() const;
std::string getGenre() const;
bool getAvailability() const;
// Setters
void setTitle(const std::string& title);
void setAuthors(const std::vector& authors);
void setPublicationYear(int publicationYear);
void setGenre(const std::string& genre);
void setAvailability(bool available);
// Other methods
void addAuthor(AuthorNarrator* author);//Adds an author to the book's list of authors
void removeAuthor(AuthorNarrator* author);//Removes an author the book's list of authors
void borrowBook();//Handles the process of borrowing the book
void returnBook();//Handles the process of returning the book
};.......................................................................#ifndef LIBRARY_H
#define LIBRARY_H
#include
#include
#include "Book.h"
class Library {
private:
std::string name;
std::vector books;
public:
// Constructor
Library(const std::string& name);//initializes a library with a given name
// Destructor
~Library();//cleans up memory for book
// Getters
std::string getName() const;//returns the name of the library
std::vector getBooks() const;//returns the list of books in the libary
// Setters
void setName(const std::string& name);//sets the name of the library
// Other methods
void addBook(Book* book);//add a book to the library's collection
void removeBook(Book* book);//removes a book from the library's collection
void listBooks() const;//lists all books in the library
Book* findBookByTitle(const std::string& title) const;//finds a book by it's title in the library
};...............................

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions