Question
Design a class bookType that define the book as an ADT. Some of the characteristics of a book are the title, author(s), publisher, ISBN, price,
Design a class bookType that define the book as an ADT.
Some of the characteristics of a book are the title, author(s), publisher, ISBN, price, and year of publication. Design a class bookType that defines the book as an ADT. i. Each object of the class bookType can hold the following information about a book: title, up to four authors, publisher, ISBN, price, and number of copies in stock. To keep track of the number of authors, add another member variable.
ii. Include the member functions to perform the various operations on objects of type bookType. For example, the usual operations that can be performed on the title are to show the title, set the title, and check whether a title is the same as the actual title of the book. Similarly, the typical operations that can be performed on the number of copies in stock are to show the number of copies in stock, set the number of copies in stock, update the number of copies in stock, and return the number of copies in stock. Add similar operations for the publisher, ISBN, book price, and authors. Add the appropriate constructors and a destructor (if one is needed).
TEMPLATE
#include
#include
#include
#include "bookType.h"
using namespace std;
void getBookData(bookType books[], int& noOfBooks);
void printBookData(bookType books[], int noOfBooks);
void searchBookData(bookType books[], int bookCount);
void searchBookDataByISBN(bookType books[], int bookCount, string ISBN,
int& loc);
void searchBookDataByTitle(bookType books[], int bookCount, string title,
int& loc);
void updateCopiesInStock(bookType books[], int bookCount);
void showMenu();
void subMenu();
int main()
{
bookType books[100];
int numberOfBooks = 0;
int choice;
getBookData(books, numberOfBooks);
showMenu();
cin >> choice;
while(choice != 9)
{
// TODO
}
return 0;
}
void getBookData(bookType books[], int& noOfBooks)
{
string title;
string ISBN;
string Publisher;
int PublishYear;
string auth[4];
double cost;
int copies;
int authorCount;
int i, j;
ifstream infile;
char ch;
infile.open("bookData.txt");
if (!infile)
{
cout << "Cannot open Input file" << endl;
cout << "Exit the program" << endl;
return;
}
infile >> noOfBooks;
infile.get(ch);
for (i = 0; i < noOfBooks; i++)
{
getline(infile, title);
getline(infile,ISBN);
getline(infile,Publisher);
infile >> PublishYear >> cost >> copies >> authorCount;
infile.get(ch);
for (j = 0; j < authorCount; j++)
getline(infile, auth[j]);
books[i].setBookInfo(title, ISBN, Publisher,
PublishYear, auth, cost, copies,
authorCount);
}
}
void printBookData(bookType books[], int noOfBooks)
{
// TODO
}
void searchBookDataByISBN(bookType books[], int bookCount, string ISBN,
int& loc)
{
// TODO
}
void searchBookDataByTitle(bookType books[], int bookCount, string title,
int& loc)
{
// TODO
}
void searchBookData(bookType books[], int bookCount)
{
// TODO
}
void updateCopiesInStock(bookType books[], int bookCount)
{
// TODO
}
void showMenu()
{
cout << "Welcome to Rock's Book Store" << endl;
cout << "To make a selection enter the number and press enter"
<< endl;
cout << "1: Print a list of books" << endl;
cout << "2: Print a list of books and ISBN numbers" << endl;
cout << "3: To see if a book in store" << endl;
cout << "4: To update the number of copies of a book" << endl;
cout << "5: To print books data" << endl;
cout << "9: Exit the program." << endl;
}
void subMenu()
{
cout << "Enter" << endl;
cout << "1: To search the book by ISBN" << endl;
cout << "2: To search the book by title" << endl;
}
bookData.txt | bookType.h | bookTypeImp.cpp |
5 C++Programing: From Problem Analysis to Program Design 5-17-525281-3 ABC 2000 52.50 20 1 Malik, D.S. Fuzzy Discrete Structures 3-7908-1335-4 Physica-Verlag 2000 89.00 10 2 Malik, Davender Mordeson, John Fuzzy Mathematic in Medicine 3-7908-1325-7 Physica-Verlag 2000 89.00 10 3 Mordeson, John Malik, Davender Cheng, Shih-Chung Harry John and The Magician 0-239-23635-0 McArthur A. Devine Books 1999 19.95 10 3 Goof, Goofy Pluto, Peter Head, Mark Dynamic InterWeb Programming 22-99521-453-1 GNet 1998 39.99 25 1 | #include using namespace std;
class bookType { public: // TODO bookType(); private: string bookTitle; string bookISBN; string bookPublisher;
int bookPublishYear; string authors[4];
double price; int quantity;
int noOfAuthors; }; | #include #include #include "bookType.h"
using namespace std;
void bookType::bookType() { // Default constructor }
// TODO other methods of bookType |
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