Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Pleased do it in C + + create a BookList Class: Your program must keep track of the following information about each book in the

Pleased do it in C ++ create 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.P PP
Sample output:
[ohsh@cs1 lab2]$ g++-ansi -pedantic -Wall -Werror -std=c++11 lab2.cpp BookList.cpp -o lab2
[ohsh@cs1 lab2]$ ./lab2
Enter books file: /home/fac/ohsh/submit/24wq2430/files/p1-files/books.txt
# of books: 55
1, Douglas Adams, The Hitchhiker's Guide To The Galaxy, 1979
2, Richard Adams, Watership Down, 1972
3, Mitch Albom, The Five People You Meet in Heaven, 2003
4, Laurie Halse Anderson, Speak, 1999
5, Maya Angelou, I Know Why the Caged Bird Sings, 1969
6, Jay Asher, Thirteen Reasons Why, 2007
7, Isaac Asimov, Foundation Series, 1951-1993
8, Ann Brashares, The Sisterhood of the Traveling Pants, 2001
9, Libba Bray, A Great and Terrible Beauty, 2003
10, Dan Brown, The Da Vinci Code, 2003
11, Meg Cabot, The Princess Diaries, 2000
12, Orson Scott Card, Ender's Game, 1985
13, Tom Clancy, The Hunt for Red October, 1984
14, Suzanne Collins, The Hunger Games, 2008
15, F. Scott Fitzgerald, The Great Gatsby, 1925
16, John Flanagan, Ranger's Apprentice Series, 2004-2011
17, Cornelia Funke, Inkheart, 2003
18, William Gibson, Neuromancer, 1984
19, William Golding, Lord of the Flies, 1954
20, William Goldman, The Princess Bride, 1973
21, James Gurney, Dinotopia: A Land Apart from Time, 1992
22, Will Hobbs, Far North, 1996
23, Alice Hoffman, Practical Magic, 1995
24, Aldous Huxley, Brave New World, 1931
25, Guy Gavriel Kay, The Summer Tree, 1984
26, Daniel Keyes, Flowers For Algernon, 1966
27, Patrice Kindl, Owl in Love, 1993
28, Masashi Kishimoto, Naruto, 1997
29, Tite Kubo, Bleach (graphic novel),2001-2016
30, Elizabeth Laird, Kiss the Dust, 1991
31, Harper Lee, To Kill a Mockingbird, 1960
32, C.S. Lewis, The Lion the Witch and the Wardrobe, 1984
33, Robert Ludlum, The Bourne Series, 1980-1990
34, Yann Martel, Life of Pi,2001
35, Lurlene McDaniel, Breathless, 2009
36, Stephenie Meyer, Twilight Series, 2005-2008
37, Garth Nix, Sabriel, 1995
38, George Orwell, Nineteen Eighty-Four (1984),1949
39, Christopher Paolini, Eragon, 2002
40, Gary Paulsen, Hatchet, 1987

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

Database Concepts

Authors: David Kroenke

4th Edition

0136086535, 9780136086536

More Books

Students also viewed these Databases questions

Question

Tell me what you know about our organization and the position.

Answered: 1 week ago