Collection App with Two Classes and Dynamic C- Strings
Introduction
In this program, you will add another class for managing the array of items. Start by looking at the lecture on classes part II for advice on how to design this class. Also, we will be changing any static C string type to a dynamic C string type. And do a makefile and a git repo for this assessment.
Again, try and keep it reasonably simple to do by the due date but still meets the requirements listed below. You will be graded mainly on how well you follow the listed requirements.
Requirements
PLEASE SEE THE GENERAL REQUIREMENTS FOR FURTHER REQUIREMENTS NEEDED. BELOW IS NOT ALL THE REQUIREMENTS NEEDED IN YOUR CODE.
Tasks
Your program should have as a minimum the following tasks (see assessment 1 and 2 for more details on some of these tasks):
a. Allow the user to add as many entries as they want to the collection.
b. Allow the user to print out the entire collection.
c. Allow the user to delete an entry from the collection.
d. Allow the user to read in items from a file.
e. Allow the user to write out items to a file.
Other tasks can be added but only if the above tasks are also present and working correctly. Extra tasks will be graded for completeness and correctness so make sure they work too.
Code Requirements
The program also needs to have the following in your code and directory:
1. There should be TWO classes in your code. One class, which will be a data
class, will be for an item in the list. If yoare using the assessment 2 class, make sure to change any static C strings to dynamic C strings. The other class, called a collection class, is for holding the array of items plus a count of items. The array and count should be the only two member variables in your collection class. If you are using your assessment 2 code, all of the task functions should be moved into this class from the main file. Leave any functions that don't deal with the array in the main file. See lecture on classes part II on more details of how to re-design your assessment 2 code for assessment 4.
2. The code for each class should be in two separate files: a .h header file and a .cpp implementation file. This is beside the main.cpp file so, in all, you need to turn in at least FIVE code files.
3. Member variables must be declared in the private section of the class. Member functions can be declared public if they need to be accessed outside of the class; otherwise they should be private too.
4. The data class (the item class) should have following: a. Getters and setters for all member variables.
b. Default constructor
c. Copy constructor
d. Operator Overloading of the assignment operator (=)
e. Destructor
5. The collection class must have at least a default constructor to initialize the count variable to zero. Other special functions are optional. If you are using any dynamic variables, you need to have a destructor to delete the memory.
6. There should be a makefile in your directory. I will be using it to compile your code.
7. There should also be a git repo in your directory. Again, make sure all code is committed.
Output:
Example Output Runs
Here are 4 runs. Note that any files written out can be read back in when running the program again. Also, reading in will append to the end of the array.
----------------------
RUN 1
----------------------
*** BOOK COLLECTION ***
== Main Menu ==
1 -> read in books from a file
2 -> write out books to a file
3 -> add books to the collection
4 -> print all books
5 -> delete a book from the collection 6 -> quit the program
Please enter a choice (1 to 6)
4
no books in collection
== Main Menu ==
1 -> read in books from a file
2 -> write out books to a file
3 -> add books to the collection
4 -> print all books
5 -> delete a book from the collection
6 -> quit the program
Please enter a choice (1 to 6)
1
Enter file name? books.txt
== Main Menu ==
1 -> read in books from a file
2 -> write out books to a file
3 -> add books to the collection
4 -> print all books
5 -> delete a book from the collection
6 -> quit the program
Please enter a choice (1 to 6)
4
---- 0 ----
title: The Name Of The Wind
author: Patrick Roth
year: 2007
---- 1 ----
title: Lord Of The Rings: The Fellowship of the Ring author: J. R. R. Tolkien
year: 1954
---- 2 ----
title: Mistborn