booktype (autosaved)

Upload: juahir-bk

Post on 10-Apr-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/8/2019 booktype (Autosaved)

    1/7

    class bookType{private:

    string author[4]; //up to four authors

    public:bookType();//Default constructor//Initializes data members

    bookType(string, string, string, double, int, int,string[]);

    //Parameter constructor//Initializes data members to user-defined values

    //*************Begin FunctionGetters/Accessors********************

    void getAuthors(string a[]);//Function to return the authors of the book//Postcondition: The values of author array are returned

    //*************Begin FunctionSetters/Mutators********************

    void setAuthors(string a[], int size);

    //Function to set the array data member author//Postcondition: author[i] = a; Max no. of authors is

    four

    //*************Begin Update Functions********************

    void updateCopies(int a);//Function to update the no. of book copies by specified

    amount//Postcondition: copies += a

    bool updateAuthorCount();//Function to update the author count by one//Postcondition: authorCount++; true if successful, false

    otherwise

    //*************Begin Equals Functions********************

    bool equalsTitle(string t);//Function to check book titles for equality//Postcondition: title == t; True if equal, false

    otherwise

  • 8/8/2019 booktype (Autosaved)

    2/7

  • 8/8/2019 booktype (Autosaved)

    3/7

    {if(author[i] != "" || author[i] != "\0")

    a[i] = author[i];}

    }

    //*************Begin FunctionSetters/Mutators********************

    void bookType::setAuthors(string a[], int size){

    for(int i=0; i < size; i++){

    author[i] = a[i];}

    }//Function to set the array data member author//Postcondition: author[i] = a; Max no. of authors is

    four

    //*************Begin Update Functions********************

    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

    //*************Begin Print/DisplayFunctions********************

    void bookType::showAuthors() const{

    for(int i=0; i < authorCount; i++){

  • 8/8/2019 booktype (Autosaved)

    4/7

  • 8/8/2019 booktype (Autosaved)

    5/7

    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());

    noOfBooks++; //Increment no. of books

    //Use search functions//1. Search by Titlecout

  • 8/8/2019 booktype (Autosaved)

    6/7

    cout

  • 8/8/2019 booktype (Autosaved)

    7/7

    {if(b[i].equalsISBN(isbn)){

    count++;index = i;

    }}

    return count;}