Question: class bookType { public: void setBookTitle(string s); //sets the bookTitle to s void setBookISBN(string ISBN); //sets the private member bookISBN to the parameter void setBookPrice(double
class bookType
{
public:
void setBookTitle(string s);
//sets the bookTitle to s
void setBookISBN(string ISBN);
//sets the private member bookISBN to the parameter
void setBookPrice(double cost);
//sets the private member bookPrice to cost
void setCopiesInStock(int noOfCopies);
//sets the private member copiesInStock to noOfCopies
void printInfo() const;
//prints the bookTitle, bookISBN, the bookPrice and the //copiesInStock
string getBookISBN() const;
//returns the bookISBN
double getBookPrice() const;
//returns the bookPrice
int showQuantityInStock() const;
//returns the quantity in stock
void updateQuantity(int addBooks);
//adds addBooks to the quantityInStock, so that the quantity //in stock now has it original value plus the parameter sent //to this function
private:
string bookTitle;
string bookISBN;
double price;
int quantity;
};
a) Write the function defintion for getBookPrice. (Write the actual code for the function. It would be in the implementation .cpp file)
b) Write the function definition for updateQuantity. (Write the actual code for the function. It would be in the implementation .cpp file.)
c) You want to add two constructors to the above class. One is the default constructor and the other is a constructor that takes four parameters and sets the bookName, bookISBN, price, and quantity to the four parameters. Show the two function prototype lines that must be added to the class definition. (YOU DO NOT HAVE TO WRITE THE FULL CONSTRUCTOR DEFINITION)
d) Assume the following in your main program (the constructors above have been written and added):
bookType bestSeller("The Help","0399155341",18.65,0);
i) Write the code in the main program that will print out the information about bestSeller.
ii) Write the code in the main program that will add 50 to the number of copies in stock for bestseller.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
