//Print method
void BookRecord::print()const
{

	string tempTitle, tempAuthor, tempPublisher;
		
	if(getTitle().length() > 22)
		tempTitle = getTitle().substr(0,22);
	else
		tempTitle = getTitle();
	
	if(getAuthor().length() > 22)
		tempAuthor = getAuthor().substr(0,22);
	else
		tempAuthor = getAuthor();
	
	if(getPublisher().length() > 22)
		tempPublisher = getPublisher().substr(0,22);
	else
		tempPublisher = getPublisher();
	
	//Re-initialize our output settings
	cout.setf(ios::left, ios::adjustfield);
	cout << setfill(' ');
	
	//Print the title, author, and publisher
	cout << setw(22) << tempTitle << " ";
	cout << setw(22) << tempAuthor << " "; 
	cout << setw(22) << tempPublisher << " ";
	
	//Prints the ISBN number
	cout.setf(ios::right, ios::adjustfield);
	cout << setw(10) << setfill('0') << getISBN();
	cout << setfill(' ') << " ";

}
Exemple #2
0
    //Displas Book`s detail
    void book::display(){

            cout<<"\nBook`s Detail:-";
            cout<<"\nItem ID:"<<getID();
            cout<<"\nTitle:"<<getTitle();
            cout<<"\nPrice:RM"<<getPrice();
            cout<<"\nQuantity:"<<getQuantity();
            cout<<"\nAuthor:"<<getAuthor();
            cout<<"\nPublisher:"<<getPublisher();
            cout<<"\nISBN:"<<getISBN();
            cout<<endl;
    }
//Comparers
int BookRecord::compareByISBN(BookRecord other)const
{

	return getISBN() - other.getISBN();

}