Question: You will write four files for this assignment: book.h , book.cpp , book _ store.h , and book _ store.cpp . All four of these
You will write four files for this assignment: book.h book.cpp bookstore.h and bookstore.cpp All four of these files will need to be submitted to the GradeoMatic. book.h This header file will contain the class definition for a class called book. The book class represents inventory information about a single book title. The header file should include an appropriate set of header guards to prevent it from being included more than once in the same source file. Data Members The book class should have the following private data members: An ISBN a string A title a string A price a floatingpoint variable A quantity in stock an integer variable Member Functions The book class definition should contain public prototypes for all of the member functions list in the book.cpp description below. book.cpp This source code file will contain the member function definitions for the book class. The required member functions are described below: Default constructor The default constructor should set the ISBN and title data members to the string literal "None". The price and quantity in stock data members should be set to Alternate constructor The alternate constructor should take four parameters: a reference to a constant string the ISBN of the book another reference to a constant string the title of the book a floatingpoint number the price of the book and an integer the quantity of the book in stock The data members of the object should be initialized to these parameters. getisbn This accessor member function has no parameters. It should return the ISBN. getprice This accessor member function has no parameters. It should return the price. fulfillorder This member function takes one parameter, an integer that represents the quantity of this book that has been ordered. The function returns an integer, which is the quantity of this book that the bookstore is actually able to ship at this time. The logic for this function should be as follows: o If the order quantity is less than zero, the order is in error. The number shipped should be zero. Do not alter the quantity in stock for the book. o If the order quantity is less than or equal to the quantity in stock, the order can be completely filled. The number shipped should be the same as the order quantity, and the order quantity should be subtracted from the quantity in stock. o Otherwise, this order cannot be completely filled. The number shipped should be the quantity in stock, and the quantity in stock should be set to zero. print This member function takes no parameters and returns nothing. The method should print the ISBN, title, price, and quantity members on the console using cout. Use setw to line the printed values up in columns a width of for the ISBN, for the title, for the price, and for the quantity will match the sample output The ISBN and title should be left justified; the price and quantity should be right justified. The price should be printed using fixedpoint notation with two places after the decimal point. bookstore.h This header file will contain the class definition for a class called bookstore. The bookstore class represents information about a collection of books. The header file should include an appropriate set of header guards to prevent it from being included more than once in the same source file. Data Members The bookstore class should have the following two private data members: An array of book objects. An integer that represents the number of elements of the book array that contain valid data. Member Functions The bookstore class definition should contain public prototypes for all of the member functions in the bookstore.cpp source code file described below. bookstore.cpp This source code file will contain the member function definitions for the bookstore class. The required member functions are described below: Default constructor The default constructor should set the number of books data member to No initialization is necessary for the array of book objects, since the book default constructor will automatically be called for every object in the array. readbooks This member function takes one parameter, a string that contains the name of a file. This string parameter can be a C string or a C string your choice The function returns nothing. This constructor should do the following: Declare and open an input file stream variable using the file name string passed in as a parameter. Check to make sure the file was opened successfully. If not, print an error message and exit the program. Read the ISBN of the first record into a local variable using the std::getline function with a colon as the delimiter. Loop while the file stream variable is not at end of file. Read each of the remaining fields of the record into local variab
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
