PLEASE ALWAYS USE CODE TAGS (the <> formatting button), to the right of this box, when posting code. Along with the proper indenting it makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/ http://www.cplusplus.com/articles/z13hAqkS/ Hint: You can edit your post, highlight your code and press the <> formatting button. This will not automatically indent your code. That part is up to you. You can use the preview button at the bottom to see how it looks. I found the second link to be the most help. |
|
|
b[3].setBook_publisher("Putnam");
there were 3 characters that would not display in my IDE, but are enough to cause an error when compiled.
|
|
|
|
|
|
|
|
BooksInfo b[nob];
is nice, but what is a "b". Consider "book" or "bookInfo". Give it a name that actually means something.
|
|
E. Functions to search the book by Book_Title and by ISBN |
|
|
|
|
|
|
using BOOKS = BooksInfo[NUM_OF_BOOKS];
. Bu adding and using this you can easily pass the array to a function by reference, which is much nicer than the pointer it degrades to, allowing you to be more efficient and be able to see the entire array not just the 1st element.
|
|
using BOOKS = BooksInfo[NUM_OF_BOOKS];
to the public section of the class before it would compile.Book Information Menu ---------------------------------------------------------------- 1. search the book by Book Title and by ISBN 2. show the number of copies in stock, set the number of copies in stock, update the number of copies in stock 3. Modifyin 4. print the information of the books 5. comparenting based on Publication Year 6. Exit Enter Your Choice: 1 BOOK SEARCH ---------------------------------------------------------------------- 1. Search by book title 2. Search by ISBN Enter choice: 1 The book's info you searched for is: Title: They Both Die at the End Author: Adam Silvera Publisher: Simon & Schuster Ltd Number of copies: 1000 ISBN#: 9781471 Price: 76.03 Publication year: 2017 |
std::cout << std::fixed << std::setprecision(2);
so the price would look correct. Adding a ($) is up to you.mar1972 wrote: |
---|
In my code in search function, i can enter the if statement ,and same as copiesinstock function and the operator overloading part in main not working |
|
|
Add the following functions in your class ... E. Functions to search the book by Book_Title and by ISBN |
|
|
F. Function to show the number of copies in stock, set the number of copies in stock, pdate the number of copies in stock, and return the number of copies in stock. |
H. An operator overloading >= function to compare two books to display which book was recently published I. An operator overloading == function to compare two books to display if the books were published in the same year |
Oh man... It's like your prof is teaching "How to be a Bad Developer 101." He/she is forcing you to do things that you'd never do in the real world. |
Using C++, write a class BooksInfo which has the following attributes: Book_Title, Book_author(s), Book_publisher, noOfCopies, ISBN, price, and Publication_Year. Add the following functions in your class ► A. A default constructor B. A constructor that sets all variables of the class ► C. A copy constructor ► D. Appropriate get and set functions to get and set all attributes E. Functions to search the book by Book_Title and by ISBN F. Function to show the number of copies in stock, set the number of copies in stock, update the number of copies in stock, and return the number of copies in stock. G. Function to modify the Book_author, Book_publisher, price H. An operator overloading >= function to compare two books to display which book was recently published I. An operator overloading == function to compare two books to display if the books were published in the same year J. A function to print the information of the class BooksInfo. Write a program to test various operations on the objects of the class booksInfo. Make a record of 25 books using Arrays of type BooksInfo. ► denotes what has been done. |
dhauden wrote: |
---|
Add the following functions in your class ... E. Functions to search the book by Book_Title and by ISBN |
BOOK SEARCH ---------------------------------------------------------------------- 1. Search by book title 2. Search by ISBN Enter choice: 2 The book's info you searched for is: Title: They Both Die at the End Author: Adam Silvera Publisher: Simon & Schuster Ltd Number of copies: 1000 ISBN#: 9781471 Price: 76.03 Publication year: 2017 The book's info you searched for is: Title: History Is All You Left Me Author: Adam Silvera Publisher: Simon & Schuster Ltd Number of copies: 1200 ISBN#: 9781471 Price: 80.94 Publication year: 2017 The book's info you searched for is: Title: How the King of Elfhame Learned to Hate Stories Author: Holly Black Publisher: Hot Key Books Number of copies: 1300 ISBN#: 9781471 Price: 102.88 Publication year: 2033 |
|
|
bool found{};
. This gives "found" the value of (0)zero or false. Then when the for loop finds a match set "found" to true. Then after the for loop add:
|
|
|
|