Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   problem in classes in c++ (http://www.go4expert.com/forums/classes-cpp-t13967/)

namrata 17Sep2008 11:10

problem in classes in c++
 
Hi there I have a question regarding class my question is Create the specification and implementation files defining a „Book‟ class. The class should have member functions for setting the title, author, ISBN number, publication year, the publisher of a book and the number of copies currently in inventory. It should also include member functions for obtaining the title, author, ISBN number, publication year, the publisher of a book and the number of copies currently in inventory of a book. The member functions should not interact with the user of the program either by providing output or by getting input. Two additional member functions should be defined that will allow more copies of the book to be added to inventory and to allow copies of the book to be removed from inventory. If the amount to remove from inventory will result in a negative number of copies, do not adjust the number of copies and return a value of „false‟ to the caller. If the value is valid, adjust the number of copies accordingly and return a „true‟ to the caller.

so far my code for header file, cpp file, and main functiuon are and so please all suggestions are welcome
Code:

class BOOK
{
public:
X    BOOK(const string & ,const string & , const string & , const string &, int , int);
X    void setTitle (const string &);
X        string getTitle () const;
X
X    void setauthor (const string &);
X        string getAuthor ()const;
X
X    void setISBN (const string &);
X        string getISBN ()const;
X
X    void setPublicationYear (int);
X        int getPublicationYear ()const;
X
X    void setPublisher (const string &);
X        string getPublisher ()const;
X
X    void setcopiesininventory(int);
X        int getcopiesininventory()const;
X    void print() const;
Xprivate:
X        string Title;
X        string Author;
X        string ISBN;
X        int PublicationYear;
X        string Publisher;
X        int copiesininventory;
};

cpp file:#include "book.h"
X
BOOK::BOOK(const string & Title ,const string & Author , const string & ISBN,
X        int PublicationYear , const string &Publisher , int copiesininventory);
X
X
{
X    Title = TITLE;
X    Author= AUTHOR;
X    ISBN  = number;
X    set PublicationYear();
X    Publisher= PUBLISHER;
X    set copiesininventory();
}
X
void BOOK::set Title(const string & TITLE)
{
X  cout<<"enter the book title"<<endl;
X  cin>>TITLE;
X    Title=TITLE;
}
string BOOK::get Title()const
{
X    return title;
}
X
void BOOK::set Author(const string & AUTHOR)
{
X    cout<<"enter the book title"<<endl;
X    cin>>TITLE;
X    Author=AUTHOR;
}
string BOOK::get Author()const
{
X        return Author;
}
void BOOK::set Publisher(const string & PUBLISHER)
{
X      Publisher = PUBLISHER;
}
string BOOK::get Publisher()const
{
X        return Publisher;
}
X
void BOOK::set copiesininventory (int copies)
{
X      copiesininventory = copies ;
}
string BOOK::get copiesininventory()const
{
X        return copiesininventory  ;
}
X
X
void BOOK::print()const
{
X    cout<<\n"Title:"<< TITLE<<endl;
X    cout<<\n"Author:"<< AUTHOR<<endl;
X    cout<<\n"ISBN:"<< number<<endl;
X    cout<<\n"PublicationYear:"<< PUBLICATIONYEAR<<endl;
X    cout<<\n"Publisher:"<< PUBLISHER<<endl;
X    cout<<\n"copiesininventory:"<< copies<<endl;
X
}
main function :
void BOOK::set Publisher(const string & PUBLISHER)
{
X      Publisher = PUBLISHER;
}
string BOOK::get Publisher()const
{
X        return Publisher;
}
X
void BOOK::set copiesininventory (int copies)
{
X      copiesininventory = copies ;
}
string BOOK::get copiesininventory()const
{
X        return copiesininventory  ;
}
X
X
void BOOK::print()const
{
X    cout<<\n"Title:"<< TITLE<<endl;
X    cout<<\n"Author:"<< AUTHOR<<endl;
X    cout<<\n"ISBN:"<< number<<endl;
X    cout<<\n"PublicationYear:"<< PUBLICATIONYEAR<<endl;
X    cout<<\n"Publisher:"<< PUBLISHER<<endl;
X    cout<<\n"copiesininventory:"<< copies<<endl;
X
}
X


xpi0t0s 17Sep2008 12:43

Re: problem in classes in c++
 
What help do you want? Does the code do what you want? If not what exactly does it do wrong and on what line?

Obviously nobody can use the code you've posted without some tedious and unnecessary editing of leading X's -- what is the point of that, and of not using a CODE block?

void BOOK::set Publisher(const string & PUBLISHER) is not the main function. int main(int argc, char *argv[]) is the main function, and is not present.

oogabooga 17Sep2008 20:50

Re: problem in classes in c++
 
Not only that, but it looks like a homework problem dump.
At least try the problem yourself before posting.
(The X's kill me! )


All times are GMT +5.5. The time now is 11:36.