Answered step by step
Verified Expert Solution
Question
1 Approved Answer
BookList Class: Your program must keep track of the following information about each book in the system: ISBN number: A number that uniquely identifies a
BookList Class:
Your program must keep track of the following information about each book in the system:
ISBN number: A number that uniquely identifies a book.
Hint: to keep things simple, this can be generated by your program ie static int
Author: The author of the book.
Title: There may be multiple books with the same title.
Year: The year or range of years if a series in which the book was published.
Beyond being able to store a list of books associated with ISBN, author, title, and year the BookList class needs to be able to add a book to the list of books, beyond what is contained in the "books.txt file. A good question to ask is what happens if my list of books implemented as an array is full. In addition, common list functionality should be included in your implementation of the BookList class.
Notes:
A reminder that printing within a class definition ie BookList.hcpp is not good practice and should be avoided. You can print in the driver ie labcpp
You may first want to look at the IntList class for ideas on list functionality ie How is this similar to the BookList class?: R: more classes
Can all the book info ie ISBN, author, title, and year for a single book or series be groupedstored together? One possibility is to use a struct: R: structs & classes
Do not create any additional classes for this project.
USE DYNAMIC MEMORY You need to create a single dynamic array in your class!
You may NOT use STL containers ie no vector, list, map, etc
Client program:
Once you have created the BookList class, create a client program main called labcpp In your client program,
Create a BookList object.
Open and read from the "books.txt file only once! and populate the book list with all the book information read from file. The user must specify the file path for the data file; however, for testing, you can download the project files here: pfiles.zip Download pfiles.zipyou will only be using "books.txt for this lab!
From P: Recommendations:
In order to grab each line ie string from a file, delimited by comma, you can use getline:
string filename "sometextfile.txt;
string str;
ifstream infile;
infile.openfilename;
whilegetlineinfile str
cout str endl;
If a delimiter is not included parameters getline will continue reading until it reaches a
character by default By including the third parameter, the getline function will stop reading further input after reaching this character delimiter ie comma
You may want to first work on printing all the information read in from files, to make sure that everything is loaded properly. Here is a sample output for this portion: P: Load file
Sufficiently tests all functionality in the BookList class. Be sure to to add all the books read in from file and print the results in main.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started