Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Assignment Overview In this assignment you will use your knowledge of functions, file 1/0, recursion, and unit testing to implement a personal library book

C++image text in transcribedimage text in transcribed

image text in transcribedimage text in transcribed

Assignment Overview In this assignment you will use your knowledge of functions, file 1/0, recursion, and unit testing to implement a personal library book management system. Your program will perform the following tasks: 1. Use File I/O to read in a list of books (title, author, publisher, and isbn) 2. Store book information into separate built-in C++ arrays 3. Allow users to search for a book based on title or author 4. Display Results to the user 5. Include a test bench for unit testing your program Input File At the start of the program you will read in a list of books from an input file using File 1/0. An example input file has been provided in your project, however we encourage you to create others to ensure your program can handle different input file sizes. The format of the input file is as follows: Example input.txt To Kill a Mockingbird, Harper Lee, Harper, 0062798189 The Giver, Lois Lowry, HMH Books for Young Readers, 9780544336261 The Hobbit,J.R.R Tolkein, Del Rey, 0345538377 The first line of the input line will contain the number of books in the library. The following lines will contain each book separated by a new line. Each book has the following information seperated by commas: Title, Author, Publisher, and ISBN (in that order). Note: It is important to note that CLion creates your program's executable in a build folder named cmake- build-debug . In File 1/0, you must specify the path of the input file in relation to the executable. For example in order to open the file you will need to do something like the following: ifstream inFile; inFile.open("../libraryBooks.txt"); // provide the path to the libraryBooks.txt file The Data Structure You will read in the books information into 4 different built-in C++ arrays. const int capacity = 100; std::string titles capacityl, authors (capacityl, publishers [capacity), isbns [capacityli Because arrays are static in size we must declare its size at runtime. You may assume that the number of books in the input file will not be more than 100. Search Menu Once the books information has been read and stored in the appropriate arrays, you will then enable a user to search for a specific title of a book, or search a book by its author. In addition, you will also allow the user to search using either an iterative function or recursive function. When searching you will return the first full match of either the title or author (depending on what they are wanting to search for). An example output is as follows: Welcome to the SMU Library! Please select an option for searching: 1. Search for Title (Iterative) 2. Search for Author (Iterative) 3. Search for Title (Recursive) 4. Search for Author (Recursive) 5. Quit Enter your selection: 1 Enter your search query: The Giver 1 Book Found! The Giver by Lois Lowry published by HMH Books for Young Readers ISBN: 9780544336261 Please select an option for searching: 1. Search for Title (Iterative) 2. Search for Author (Iterative) 3. Search for Title (Recursive) 4. Search for Author (Recursive) 5. Quit Enter your selection: 4 Enter your search query: Harper Lee 1 Book Found! To Kill a Mockingbird by Harper Lee published by Harper ISBN: 0062798189 Please select an option for searching: 1. Search for Title (Iterative) 2. Search for Author (Iterative) 3. Search for Title (Recursive) 4. Search for Author (Recursive) 5. Quit Enter your selection: 3 Enter your search query: Giver O Books Found! Notice that the title or author has to match completely (letter and case). Otherwise display that there was no book found. If a user selects option 5, you will terminate the program. Program Specifications Your program must meet the following specifications. Please read carefully You must use built-in C++ arrays ONLY (No vectors or other containers from the STL) STL strings are okay. (5pts) You must use at least 4 functions. (5pts) o These functions must be implemented in a seperate file called functions.cpp along with a header file functions.h to be included in both your program2 and test file. These files have already been provided for you. You must implement one function that uses pass by reference. (5pts) You must implement one function that uses pass by value. (5pts) You must implement one non-void function that returns a value. (5pts) Your program must implement error handling in your program. If a user enters an invalid number or value, you must display an error message notifying the user of the invalid input and prompt again. (5 pts) You may NOT use global variables (variables declared outside of main or any function) to hold the data for books. You may only use constant global variables if necessary. (5 pts) Unit Tests Your program will also include a testbench ( test.cpp ) that holds unit tests for the functions you have created for this program. The file has been provided for you. You should have 10 tests in total. You may feel free to add more to cover more test cases or other functions. You must use the assert() method from the cassert library for each unit test. _Hint: Think of the edge cases for each function. You may have multiple unit tests per function. Assignment Overview In this assignment you will use your knowledge of functions, file 1/0, recursion, and unit testing to implement a personal library book management system. Your program will perform the following tasks: 1. Use File I/O to read in a list of books (title, author, publisher, and isbn) 2. Store book information into separate built-in C++ arrays 3. Allow users to search for a book based on title or author 4. Display Results to the user 5. Include a test bench for unit testing your program Input File At the start of the program you will read in a list of books from an input file using File 1/0. An example input file has been provided in your project, however we encourage you to create others to ensure your program can handle different input file sizes. The format of the input file is as follows: Example input.txt To Kill a Mockingbird, Harper Lee, Harper, 0062798189 The Giver, Lois Lowry, HMH Books for Young Readers, 9780544336261 The Hobbit,J.R.R Tolkein, Del Rey, 0345538377 The first line of the input line will contain the number of books in the library. The following lines will contain each book separated by a new line. Each book has the following information seperated by commas: Title, Author, Publisher, and ISBN (in that order). Note: It is important to note that CLion creates your program's executable in a build folder named cmake- build-debug . In File 1/0, you must specify the path of the input file in relation to the executable. For example in order to open the file you will need to do something like the following: ifstream inFile; inFile.open("../libraryBooks.txt"); // provide the path to the libraryBooks.txt file The Data Structure You will read in the books information into 4 different built-in C++ arrays. const int capacity = 100; std::string titles capacityl, authors (capacityl, publishers [capacity), isbns [capacityli Because arrays are static in size we must declare its size at runtime. You may assume that the number of books in the input file will not be more than 100. Search Menu Once the books information has been read and stored in the appropriate arrays, you will then enable a user to search for a specific title of a book, or search a book by its author. In addition, you will also allow the user to search using either an iterative function or recursive function. When searching you will return the first full match of either the title or author (depending on what they are wanting to search for). An example output is as follows: Welcome to the SMU Library! Please select an option for searching: 1. Search for Title (Iterative) 2. Search for Author (Iterative) 3. Search for Title (Recursive) 4. Search for Author (Recursive) 5. Quit Enter your selection: 1 Enter your search query: The Giver 1 Book Found! The Giver by Lois Lowry published by HMH Books for Young Readers ISBN: 9780544336261 Please select an option for searching: 1. Search for Title (Iterative) 2. Search for Author (Iterative) 3. Search for Title (Recursive) 4. Search for Author (Recursive) 5. Quit Enter your selection: 4 Enter your search query: Harper Lee 1 Book Found! To Kill a Mockingbird by Harper Lee published by Harper ISBN: 0062798189 Please select an option for searching: 1. Search for Title (Iterative) 2. Search for Author (Iterative) 3. Search for Title (Recursive) 4. Search for Author (Recursive) 5. Quit Enter your selection: 3 Enter your search query: Giver O Books Found! Notice that the title or author has to match completely (letter and case). Otherwise display that there was no book found. If a user selects option 5, you will terminate the program. Program Specifications Your program must meet the following specifications. Please read carefully You must use built-in C++ arrays ONLY (No vectors or other containers from the STL) STL strings are okay. (5pts) You must use at least 4 functions. (5pts) o These functions must be implemented in a seperate file called functions.cpp along with a header file functions.h to be included in both your program2 and test file. These files have already been provided for you. You must implement one function that uses pass by reference. (5pts) You must implement one function that uses pass by value. (5pts) You must implement one non-void function that returns a value. (5pts) Your program must implement error handling in your program. If a user enters an invalid number or value, you must display an error message notifying the user of the invalid input and prompt again. (5 pts) You may NOT use global variables (variables declared outside of main or any function) to hold the data for books. You may only use constant global variables if necessary. (5 pts) Unit Tests Your program will also include a testbench ( test.cpp ) that holds unit tests for the functions you have created for this program. The file has been provided for you. You should have 10 tests in total. You may feel free to add more to cover more test cases or other functions. You must use the assert() method from the cassert library for each unit test. _Hint: Think of the edge cases for each function. You may have multiple unit tests per function

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

More Books

Students also viewed these Databases questions

Question

Graph the equation. y = x 2 - 3

Answered: 1 week ago