Escolar Documentos
Profissional Documentos
Cultura Documentos
{
private:
public:
bookType();
//Default constructor
//Initializes data members
bool updateAuthorCount();
//Function to update the author count by one
//Postcondition: authorCount++; true if successful, false otherwise
};
----------------------------------------------------------------------------------------------------------------
---
//bookType.cpp
bookType::bookType()
{
//Initialize variables to default values
setTitle();
setPublisher();
setISBN();
setPrice();
setCopies();
setAuthorCount();
}//End bookType
//Parameter constructor
bookType::bookType(string t, string pub, string isbn, double p, int c, int ac, string a[])
{
//Initialize variables to user-defined values
setTitle(t);
setPublisher(pub);
setISBN(isbn);
setPrice(p);
setCopies(c);
setAuthorCount(ac);
setAuthors(a, getAuthorCount());
}//End bookType
void bookType::incrementCopies()
{
copies++;
}
//Function to increment the no. of book copies by one
//Postcondition: copies++
bool bookType::updateAuthorCount()
{
bool rslt = false;
if(authorCount < 4)
{
authorCount++;
rslt = true;
}
return rslt;
}
//Function to update the author count by one
//Postcondition: authorCount++; true if successful, false otherwise
-------------------------------------------------------------------------------------------------------
------------
//main.cpp
int main()
{
int noOfBooks = 0;
Programming[2].setTitle(GameProg.getTitle());
Programming[2].setPublisher(GameProg.getPublisher());
Programming[2].setISBN(GameProg.getISBN());
Programming[2].setPrice(GameProg.getPrice());
Programming[2].setCopies(GameProg.getCopies());
Programming[2].setAuthorCount(GameProg.getAuthorCount());
Programming[2].setAuthors(gameAuthors, Programming[2].getAuthorCount());
int index = 0;
int matches = SearchTitle(Programming, noOfBooks, "Game Programming", index);
if(matches)
{
cout << "\nBook(s) Found by Title! No. of matches: " << matches << endl;
Programming[index].showBookInfo();
}
else
cout << "\nBook(s) not found by Title!" << endl;
index = 0;
matches = SearchISBN(Programming, noOfBooks, "0-619-16042-X", index);
if(matches)
{
cout << "\nBook(s) Found by ISBN! No. of matches: " << matches << endl;
Programming[index].showBookInfo();
}
else
cout << "\nBook(s) not found by ISBN!" << endl;
cout << "\nNo. of copies after update for book at index 1: " <<
Programming[1].getCopies() << endl;
cin.get();
return 0;
}
return count;
}
return count;
}