本文整理汇总了C++中Book::getIsbn方法的典型用法代码示例。如果您正苦于以下问题:C++ Book::getIsbn方法的具体用法?C++ Book::getIsbn怎么用?C++ Book::getIsbn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Book
的用法示例。
在下文中一共展示了Book::getIsbn方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Reindex_Book
void Index_file::Reindex_Book(const char* file_name, const char* index_name){
lista = new vector<Keynode>;
ifstream data_file(file_name,ios::in|ios::binary);
if(data_file.good()){
data_file.seekg(sizeof(HeaderBook));
while(!data_file.eof()){
Book book;
data_file.read(reinterpret_cast<char*>(&book),sizeof(Book));
if(!book.isMarked()){
Keynode keynode(const_cast<char *>(book.getIsbn().c_str()),data_file.tellg());
lista->push_back(keynode);
}
}
sort();
}
data_file.close();
ofstream index_file(index_name,ios::out|ios::binary);
for (int i = 0; i < lista->size(); ++i) {
Keynode to_add = lista->at(i);
index_file.write((char*)&to_add,sizeof(Keynode));
}
index_file.flush();
index_file.close();
}
示例2: displayBookInformation
void Utils::displayBookInformation(Book book) {
cout << "\tISBN \t" << book.getIsbn() << endl;
cout << "\tTitle \t" << book.getTitle() << endl;
cout << "\tAuthor \t" << book.getAuthor() << endl;
cout << "\tPublisher \t" << book.getPublisher() << endl;
cout << "\tDate Added \t" << toString(book.getDateAdded()) << endl;
cout << "\tQuantity-On-Hand\t" << book.getQuantityOnHand() << endl;
cout << "\tWholesale Cost \t" << setprecision(2) << book.getWholesaleCost() << endl;
cout << "\tRetail Price \t" << setprecision(2) << book.getRetailPrice() << endl << endl;
}
示例3: toString
/*
Converts a Book object to string representation
Example:
1
ISBN: 0399257748
Title: The Martian
Author: Andy Weir
Publisher: Scribner
Date Added: 2015-1-16 23:56:11
Quantity: 1
*/
string Utils::toString(int itemNumber, int quantity, Book book) {
string bookString = "";
bookString += to_string(itemNumber) + "\n";
bookString += "\t ISBN: " + book.getIsbn() + "\n";
bookString += "\t Title: " + book.getTitle() + "\n";
bookString += "\t Author: " + book.getAuthor() + "\n";
bookString += "\t Publisher: " + book.getPublisher() + "\n";
bookString += "\t Date Added: " + toString(book.getDateAdded()) + "\n";
bookString += "\t Quantity: " + to_string(quantity) + "\n";
ostringstream stream;
stream << fixed << setprecision(2) << book.getRetailPrice();
bookString += "\t Retail Price: " + stream.str() + "\n";
return bookString;
}
示例4: insertBook
/**
* @brief Add book \a b to the collection.
*
* @param b Book to be added.
*
* @exception DataBaseException Forwarding possible database error.
*
* @warning Make sure you DON'T SET the books id before calling this method.
*
* Adds \a b to the DataBase and sets its id. Nothing is done with the referenced
* authors, publishers and themes.
*/
void BookCollection::insertBook(Book &b) throw(DataBaseException)
{
PreparedStatement prepStmt("INSERT INTO books (isbn, title, edition, "
"critique, description, rating, cover, ebook, publishingyear, "
"udc, translator) VALUES ('%1', '%2', '%3', '%4', '%5', '%6', "
"'%7', '%8', '%9', '%10', '%11')", db->getType());
prepStmt.arg(b.getIsbn());
prepStmt.arg(b.getTitle().toStdString());
prepStmt.arg(b.getEdition());
prepStmt.arg(b.getCritique().toStdString());
prepStmt.arg(b.getDescription().toStdString());
prepStmt.arg(b.getRating());
prepStmt.arg(b.getCover().toStdString());
prepStmt.arg(b.getEbook().toStdString());
prepStmt.arg(b.getPubDate().toString("yyyy-MM-dd").toStdString());
prepStmt.arg(b.getUDC().toStdString());
prepStmt.arg(b.getTranslator().getId());
b.setId(db->insert(prepStmt));
}
示例5: updateBook
/**
* @brief Updates book.
*
* @param b Book to be updated.
*
* This method updates every field of the book, except the id and the referenced
* authors, publishers and themes.
*/
void BookCollection::updateBook(Book b) throw(DataBaseException)
{
PreparedStatement updBook("UPDATE books SET isbn = '%1', title = '%2',"
" edition = '%3', description = '%4', critique = '%5', rating ="
" '%6', cover = '%7', ebook = '%8', publishingyear = '%9', udc ="
" '%10', translator = '%11' WHERE id = '%12'", db->getType());
updBook.arg(b.getIsbn());
updBook.arg(b.getTitle().toStdString());
updBook.arg(b.getEdition());
updBook.arg(b.getDescription().toStdString());
updBook.arg(b.getCritique().toStdString());
updBook.arg(b.getRating());
updBook.arg(b.getCover().toStdString());
updBook.arg(b.getEbook().toStdString());
updBook.arg(b.getPubDate().toString("yyyy-MM-dd").toStdString());
updBook.arg(b.getUDC().toStdString());
updBook.arg(b.getTranslator().getId());
updBook.arg(b.getId());
db->exec(updBook);
}
示例6: getBookPositionInCart
/*
Check whether the given book is in the cart or not, if yes return the position, otherwise return -1
@param book : the given book
@return position : if the book is in the cart, return the position, otherwise return -1
*/
int InventoryModule::getBookPositionInCart(Book book) {
for (int i = 0; i < CashierModule::numberItems; i++)
if (CashierModule::booksInCart[i].getIsbn() == book.getIsbn())
return i;
return -1;
}
示例7: displayOptionsAfterLookUp
/*
Display available options after a desired book's information is presented and corresponding transitions
when user choose one option.
*/
void InventoryModule::displayOptionsAfterLookUp(int thingToShow, Book bookObtained) {
cout << "\t\t 1. Look Up Another Book" << endl;
cout << "\t\t 2. Back To Look Up Menu" << endl;
cout << "\t\t 3. Add This Book To Cart"<< endl << endl;
switch (Utils::showChoices(1, 3)) {
case 1:
switch (thingToShow) {
case SHOW_ISBN:
showBooksByISBN();
break;
case SHOW_TITLE:
showBooksByTitle();
break;
case SHOW_AUTHOR:
showBooksByAuthor();
break;
case SHOW_PUBLISHER:
showBooksByPublisher();
break;
case SHOW_DATE:
showBooksByDate();
break;
case SHOW_QUANTITY:
showBooksByQuantity();
break;
case SHOW_WHOLESALE:
showBooksByWholesale();
break;
case SHOW_RETAIL_PRICE:
showBooksByRetailPrice();
break;
}
break;
case 2:
displayLookUpMenu();
break;
case 3:
int howMany = 0;
do {
howMany = Utils::readInt("How Many Books Do You Want?\t");
if (howMany < 0)
cout << "Number Of Books Has To Be An Integer Greater Than 0. Please Enter Again" << endl << endl;
if (howMany > bookObtained.getQuantityOnHand())
cout << "We Only Have " << bookObtained.getQuantityOnHand() << " In Stock. Please Enter Again" << endl << endl;
} while (howMany < 0 || howMany > bookObtained.getQuantityOnHand());
int position = getBookPositionInCart(bookObtained);
if (position == -1) {
CashierModule::quantities[CashierModule::numberItems] += howMany;
CashierModule::booksInCart[CashierModule::numberItems++] = bookObtained;
}
else CashierModule::quantities[position] += howMany;
BookDAO::getInstance()->update(
bookObtained.getIsbn(),
bookObtained.getTitle(),
bookObtained.getAuthor(),
bookObtained.getPublisher(),
bookObtained.getQuantityOnHand() - howMany,
bookObtained.getWholesaleCost(),
bookObtained.getRetailPrice());
}
}
示例8: updateItemInfo
void SELMainLibraryWidget::updateItemInfo(EntertainmentItem & item,
unsigned long long type)
{
Book * bookItem = 0;
Movie * movieItem = 0;
MusicAlbum * musicItem = 0;
Videogame * videogameItem = 0;
int currentIndex = 4;
unsigned size;
/// Update title
replaceLabelText(item.getTitle().c_str(), 0);
/// Update genre
replaceLabelText(item.getGenre().c_str(), 1);
/// Update publisher
replaceLabelText(item.getPublisher().c_str(), 2);
/// Update year
replaceLabelText(QString::number(item.getYear()), 3);
/// Check type to write extra data.
switch (type) {
case 1:
bookItem = dynamic_cast<Book *>(&item);
if (bookItem != 0) {
/// Write book data
replaceLabelText("ISBN:", currentIndex++);
replaceLabelText(bookItem->getIsbn().c_str(), currentIndex++);
replaceLabelText("Authors:", currentIndex++);
size = bookItem->getAuthors().size();
for (unsigned i = 0; i < size; i++) {
replaceLabelText(bookItem->getAuthors()[i].c_str(), currentIndex++);
}
replaceLabelText("Num pages", currentIndex++);
replaceLabelText(QString::number(bookItem->getNPages()), currentIndex++);
}
break;
case 2:
movieItem = dynamic_cast<Movie *>(&item);
if (movieItem != 0) {
/// Write movie data
replaceLabelText("Director:", currentIndex++);
replaceLabelText(movieItem->getDirector().c_str(), currentIndex++);
replaceLabelText("Actors:", currentIndex++);
size = movieItem->getMainActors().size();
for (unsigned i = 0; i < size; i++) {
replaceLabelText(movieItem->getMainActors()[i].c_str(), currentIndex++);
}
replaceLabelText("Rating:", currentIndex++);
replaceLabelText(Movie::getRatingString(movieItem->getRating()).c_str(), currentIndex++);
}
break;
case 3:
musicItem = dynamic_cast<MusicAlbum *>(&item);
if (musicItem != 0) {
/// Write music data
replaceLabelText("Artist:", currentIndex++);
replaceLabelText(musicItem->getArtist().c_str(), currentIndex++);
replaceLabelText("Num tracks:", currentIndex++);
replaceLabelText(QString::number(musicItem->getNTracks()), currentIndex++);
replaceLabelText("Total duration:", currentIndex++);
replaceLabelText(musicItem->getDuration().toString("hh:mm:ss"), currentIndex++);
}
break;
case 4:
videogameItem = dynamic_cast<Videogame *>(&item);
if (videogameItem != 0) {
replaceLabelText("Rating:", currentIndex++);
replaceLabelText(Videogame::getRatingString(videogameItem->getEsrbRating()).c_str(), currentIndex++);
replaceLabelText("Platform:", currentIndex++);
replaceLabelText(Videogame::getPlatformString(videogameItem->getPlatform()).c_str(), currentIndex++);
}
break;
default:
Error::raiseError(Error::ERROR_UNKNOWN_ITEM_TYPE);
break;
}
size = itemInfo.size();
while (currentIndex < (int)size) {
itemInfo[currentIndex++]->setText("");
}
}