bookType Class problem using ADT

I am very overwhelmed and just need help starting out a solution. I received this main program along with instructions:
javascript:tx('
#include <iostream>
#include <string>
#include <fstream>
#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;

int i;

getBookData(books, numberOfBooks);

showMenu();
cin >> choice;

while (choice != 9)
{
switch (choice)
{
case 1:
for (i = 0; i <numberOfBooks; i++)
books[i].printbookTitle();
cout << endl;
break;
case 2:
for (i = 0; i <numberOfBooks; i++)
books[i].printbookTitleAndISBN();
cout << endl;
break;
case 3:
searchBookData(books, numberOfBooks);
break;
case 4:
updateCopiesInStock(books, numberOfBooks);
break;
case 5:
printBookData(books, numberOfBooks);
break;
default:
cout << "Invalid selection." << endl;
}

showMenu();
cin >> choice;
}

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)
{
int i;

for (i = 0; i < noOfBooks; i++)
{
books[i].printInfo();
cout << endl << "---------------------------------" << endl;
}
}

void searchBookDataByISBN(bookType books[], int bookCount, string ISBN,
int& loc)
{
int i;
loc = -1;

for (i = 0; i < bookCount; i++)
if (books[i].isISBN(ISBN))
{
loc = i;
break;
}
}

void searchBookDataByTitle(bookType books[], int bookCount, string title,
int& loc)
{
int i;
loc = -1;

for (i = 0; i < bookCount; i++)
if (books[i].isTitle(title))
{
loc = i;
break;
}
}

void searchBookData(bookType books[], int bookCount)
{
int choice;
char ch;

int loc;

string str;

subMenu();

cin >> choice;
cin.get(ch);

switch (choice)
{
case 1:
cout << "Enter the ISBN of the book." << endl;
getline(cin, str);
searchBookDataByISBN(books, bookCount, str, loc);
if (loc != -1)
cout << "The store sells this book." << endl;
else
cout << "The store does not sell this book" << endl;
break;
case 2:
cout << "Enter the title of the book." << endl;
getline(cin, str);
searchBookDataByTitle(books, bookCount, str, loc);
if (loc != -1)
cout << "The store sells this book." << endl;
else
cout << "The store does not sell this book" << endl;
break;
default:
cout << "Invalid choice" << endl;
}
}

void updateCopiesInStock(bookType books[], int bookCount)
{
int choice;

int loc;

int count;
char ch;

string str;

subMenu();
cin >> choice;
cin.get(ch);

switch (choice)
{
case 1:
cout << "Enter the ISBN of the book." << endl;
getline(cin, str);
searchBookDataByISBN(books, bookCount, str, loc);
if (loc != -1)
{
cout << "Enter the number of books: ";
cin >> count;
cout << endl;

books[loc].updateQuantity(count);
}
else
cout << "The store does not sell this book: " << endl;
break;
case 2:
cout << "Enter the title of the book." << endl;
getline(cin, str);
searchBookDataByTitle(books, bookCount, str, loc);
if (loc != -1)
{
cout << "Enter the number of books";
cin >> count;
cout << endl;

books[loc].updateQuantity(count);
}
else
cout << "The store does not sell this book" << endl;
break;
default:
cout << "Invalid choice" << endl;
}
}

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;
}

')
Instructions:
- 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.
- 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).
- Write the definitions of the member functions of the class bookType.

So far I have come up with this:
javascript:tx('#include <string>

using namespace std;

class bookType
{
public:
//constructors & destructors
bookType();
~bookType();

//setters
void setBookInfo(string, string, string, int, string, int, int, int);

//getters
void getBookData(bookType, int);

void searchBookDataByISBN(bookType, int, string, int);
void searchBookDataByTitle(bookType, int, string, int);
void searchBookData(bookType, int);
void updateCopiesInStock(bookType, int);
void updateQuantity(int);

void printBookData(bookType, int);
void printbookTitle(string);
void printbookTitleAndISBN(string, int);
void printInfo(bookType);

bool isISBN(int ISBN) const;
bool isTitle(string title);


private:
string title;
string auth[4];
string Publisher;
string ISBN;
int copies;
int authorCount;
int PublishYear;
int cost;
};

bookType::bookType() {
title = "";
auth[0] = "";
auth[1] = "";
auth[2] = "";
auth[3] = "";
Publisher = "";
ISBN = "";
authorCount = 0;
copies = 0;
PublishYear = 0;
cost = 0;
}

bookType::~bookType() {
}

//setBookInfo(title, ISBN, Publisher, PublishYear, auth, cost, copies, authorCount)
void bookType::setBookInfo(string newtitle, string newISBN, string newPublisher, int newPublishYear, string newAuth[4], int newcost, int newcopies, int newAuthorcount) {
title = newtitle;
ISBN = newISBN;
Publisher = newPublisher;
PublishYear = newPublishYear;
auth[4] = newAuth[4];
cost = newcost;
copies = newcopies;
authorCount = newAuthorcount;
}')

Any help is appreciated;
Last edited on
Topic archived. No new replies allowed.