I have to make a Book class with members for the ISBN, title, author, and copyright, as well as checked in/out status. Functions that return those data value has to be made, as well as a status checker. The thing I'm having most problem figuring out is that ISBN has to be of the form integer-integer-integer-integer-char.
So far, this is what I have, copying from the Date class example the book gave me =(.
There are four parts to the ISBN: Group, Publisher, Title, and Check Digit. All four parts are numbers except the last one. It is a check digit modulo base 11. Because there is no way to represent 11 as one character in base 10, an 'X' is used in the case of a check digit being 11.
For this program, the easiest way to store the ISBN is as a character array.
When the book asked for ISBN, it meant the regular 13 digit code. However, it also asks for the actual title/copyright date/checked in status/etc... In other words, when I call for a Book A, it's supposed to output
123-456-789-101-b, William Shakespeare, Romeo and Juliet 5th Edition, Fiction, 5/5/2005, checked out
In other words, when I call for a Book A, it's supposed to output
123-456-789-101-b, William Shakespeare, Romeo and Juliet 5th Edition, Fiction, 5/5/2005, checked out
First, as kooth has mentioned, you need to re-design how you want to hold the isbn variable. Do you want a character array or C++ string ?
Second, what do you mean when I call for a Book A, do you mean
1 2 3 4 5 6 7 8 9
Book bookA;
bookA.isbn(); //it is supposed to output "123-456-789-101-b, William Shakespeare, Romeo and
//Juliet 5th Edition, Fiction, 5/5/2005, checked out"
OR
Book bookA;
cout << bookA; //it is supposed to output "123-456-789-101-b, William Shakespeare, Romeo
//and Juliet 5th Edition, Fiction, 5/5/2005, checked out"
@sohguanh
It's the latter which I believe the book asks for. As to the isbn variables, I wouldn't know how to set them as an array of characters. But I think that string is the solution, but since it asks to check for integer or character, I guess I have to manually use a code to check if a string qualifies for either.
Here are the exact instructions; like I said, I'm not entirely sure what it means.
This exercise and the next few require you to design and implement a Book class, such as you can imagine as part of software for a library. Class Book should have members for the ISBN, title, author, and copyright date. Also store data on whether or not the book is checked out. Create functions for returning those data values. Create functions for checking a book in and out. Do simple validation of data entered into a Book; for example, accept ISBNs only of the form n-n-n-x where n is an integer and x is a digit or letter.
Right now just playing around with codes individually to see if they work. But when I take class into consideration, I get a plethora of errors. xD. Oh well, one step at a time.
I am also using Stroustrup's book to teach myself C++ programming. I did the same exercise last month and asked for help on this forum. I think the title of my thread was "Constructive Criticism Appreciated". I think I posted it 2 or 3 weeks ago. If you find the thread you can look at my code and the suggestions for improvement that forum members posted in reply. That should help you with writing your own program for the exercise.
As for the ISBN, use the format that Stroustrup indicated in the exercise, n-n-n-x. The letter 'n' represents ONE INTEGER, not a number of any length. So an example of an ISBN for this exercise is '5-9-0-q', defined as a string. Remember the KISS principle and the fact we are learning programming, not library science.