Question
Program definition: Design a class bookType that defines a book as a class. Each object of the class bookType will hold the following information about
Program definition:
Design a class bookType that defines a book as a class.
- Each object of the class bookType will hold the following information about a book:
title
number of authors
up to four authors
publisher
year published
ISBN 13 (with dashes)
price
number of copies in stock (may be 0)
- Include the member functions to perform the various operations on objects of type bookType: get and set all member variables.
- Add a member function to update the number of copies in stock.
- Add the appropriate constructors and a destructor (if one is needed). Ensure a default constructor is coded and the constructor initializes all data members. Remember, an array of classes uses a default constructor only.
- ALL member variables must be private and accessed through member functions. The main client program CANNOT access the variables directly.
- Ensure the class declaration and class implementation files are in separate header and code (.cpp) files. This assignment will require the creation of a project.
- Write a client program that uses the class bookType and tests various operations on the objects of the class bookType. Declare an array of 100 components of type bookType in the client program.
- Using a function, open the attached datafile (bookData.txt). Request the file name from the user. If the file does not open, display a proper message and exit the program. The file open should be in main and test a return value of success or failure.
- Use a function and the attached datafile (bookData.txt) to initially load the data. The data file is of the form:
Book Title
ISBN
Publisher
Year Published
Cost
Number In Stock
Number of Authors
List of Authors
- Read until end of file. Do not hardcode and use the actual number of books as the maximum (limiting factor) for the array of books. Keep a count of actual rows read and pass into and out of any functions and processes.
- Have the program provide the following capabilities (by user request):
Through a menu system provide the capability to:
- Search for a book by ISBN, Author or Book title. If the store sells the book, return an appropriate message. If the store does not sell the book, return an appropriate message. If the store sells the book, print the Title, authors, ISBN, publisher, price and the number in stock for the book.
- Print a list of ALL the books in stock. This list will include all the information available for a book. A book is in stock when the number in stock is greater than 0.
- Update the number of copies in stock. The user may search for the book using one of the capabilities indicated in (1) (by ISBN, Author or Title) and add to the number of copies by the number entered. This will simulate the process of restocking.
- Print a list of ALL the books the store sells, even if not in stock at the time. The list will include all the information available for a book.
- The user may exit the program by keying in an exit command or choice determined by you.
- Place all function prototypes and const variables for the client program in a header file. Include the header file in the client program.
- Include error checking (invalid choices, file open errors, etc.)
Once your class is declared and defined and your client program written, test each of the menu options to ensure proper processing and program behavior.
All classes must have a class definition header file (*.h) and a class implementation file (*.cpp). You must have a main program that exercises these classes (*.cpp).
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