Question: #ifndef _BOOK_H_ #define _BOOK_H_ // These two lines of preprocessor directives, and the one at the end #endif, // prevent the header file from being
#ifndef _BOOK_H_
#define _BOOK_H_
// These two lines of preprocessor directives, and the one at the end #endif,
// prevent the header file from being included (linked in) multiple times,
// when it is used multiple times by the user.
#include "Buy.h"
#include
using namespace std;
class Book {
private:
string title, author; // private local variables
float price;
public:
Book(string,string,float); // constructor
Buy *buys; // linked list of buy
// accessor methods
string getTitle();
string getAuthor();
float getPrice();
void setTitle(string);
void setAuthor(string);
void setPrice(float);
// class methods
void buyBook(string date);
string displayBought();
int timesBought();
string toString();
};
#endif // _BOOK_H_
#include "Book.h" #include
// Q1 : CLASS METHODS Part 1 : Constructor, Accessor, and Set Methods for Book (5 points)
// Constructor // Create a constructor for the class Book which takes 2 string parameters and one float parameter. // Use the parameters to initialize the three private local variables title, author, and price. // HINT: Don't forget to initialize your linked list of buys to NULL.
// code here
// Accessor and Set Methods // Create accessor and set methods for private local strings title and author and also float price.
// code here
// Q2 : CLASS METHODS Part 2 : Class Methods for Book (10 points)
// Create a method called "toString" // This method has no input parameters and returns the string containing the title, author, and price of a book. // This function is used in print_all function inside main to print the information of a book. // The exact format can be found in the sample output of assignment description.
// code here
// Create a method named "buyBook" which has one string parameter date and no return type (see helper function for use). // This method is used to add a new date to the book's linked list of buys. The string parameter is the date of buying. // You should add the date to the tail of the linked list "buys". Buys will be added in chronological order.
// code here
// Create a method named "timesBought" // This method has no input parameters and returns the number of times the book has been bought. // This function is used in print_all function inside the main function.
// code here
// Create a method named "displayBought" which has no parameters and returns a string (see print_all function for use). // This method will be used to return a string for the dates where the book has been bought. // If the book was not bought, return an empty string.
// code here]
I have no clue what I have to do in order to get constructors, methods, accessors, and things like the questions ask... Pleas help.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
