Answered step by step
Verified Expert Solution
Link Copied!

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 (i.e. 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 (i.e. BookList.h/cpp) is not good practice and should be avoided. You can print in the driver (i.e. lab2.cpp).
You may first want to look at the IntList class for ideas on list functionality (i.e. How is this similar to the BookList class?): R2-4: more classes
Can all the book info (i.e. ISBN, author, title, and year) for a single book or series be grouped/stored together? One possibility is to use a struct: R2-1: 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 (i.e. no vector, list, map, etc).
Client program:
Once you have created the BookList class, create a client program (main) called lab2.cpp. 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: p1-files.zip Download p1-files.zip(you will only be using "books.txt" for this lab!)
From P1: Recommendations:
In order to grab each line (i.e. string) from a file, delimited by comma, you can use getline():
string filename = "sometextfile.txt";
string str;
ifstream infile;
infile.open(filename);
while(getline(infile, str,',')){
cout << str << endl;
}
If a delimiter is not included (2 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 (i.e. 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: P1: 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Databases Concepts And Practice

Authors: Suzanne W Dietrich

1st Edition

1119827949, 9781119827948

Students also viewed these Databases questions