Project 1

§1 Project 1 #

The owner of a small bookstore is looking to modernize their store’s inventory system with new software. This software will track and store inventory information about all the books in the store.

§2 Info #

For this project, you are going to decide how to structure your program, including data representation, function parameters, and return types. You have the flexibility to implement it in any way that meets the rubric requirements. Your grade will be based solely on how well you fulfill those criteria.

I encourage you to review the posts and feedback from last week’s discussion board. This project will serve as a culmination of many of the concepts you have learned so far. Unlike small assignments, larger projects present unique challenges and pitfalls in software development that are not immediately apparent.

The decisions you make throughout this project will significantly impact the structure and functionality of your final program. It is common to realize, after writing some code, that initial choices need to be revised or restructured to improve the overall design. This process of iteration and refinement is a key part of software development.

Future projects will build on the code you develop now and will introduce more complex requirements. It will be helpful to write your code with scalability and adaptability in mind. Consider how your codebase can be reused, extended, or refactored as new features and requirements are added. Here are some important considerations:

By keeping these points in mind, you should develop a more robust and maintainable codebase that can handle the growing complexity of future assignments.

Be aware that your source code will be shown to the rest of the class, as we will perform a “code review” of your project implementation.

§3 Guidelines #

You may use a single file or several files for your source code.

You may utilize any combination of containers to represent the list of books in your program, this could be arrays, structs, vectors, lists, etc.

Here is a list of features for your Inventory Management Software:

  1. Book Information:
  1. Output:

    Consider whether you should use operator<< overloading or functions to implement the output functionality. Both approaches are valid and come with trade-offs.

  1. Search and Sorting Features:

    Take time to carefully consider how your functions should return data, as there are multiple approaches to choose from. For example, you could use void functions that simply print the output, functions that return new lists containing subsets of books, or functions that return references to books within an existing list.
    Each choice has trade-offs in terms of modularity and complexity. A key objective of this project is to help you gain experience with integrating code into a larger project, where seemingly minor decisions about your design can significantly impact the overall structure of your program.

  1. Purchasing:
  1. Limitations:

§4 Test Case #

All test cases are already outlined in the example starter.cpp file. You just need to add functionality for each section.

Most of your logic should be implemented outside of main(); your main() should primarily consist of calls to other functions, and perhaps some basic loops to iterate over your book list.

§5 Grading Rubric #

All tests will be verified with multiple different input files.

Your grade is based on adherence to the rubric.

Use tests/validate.py to check your work; it will let you know if any sections are incomplete.

NOTE: While I tried to make the test as forgiving as possible, you may have creative edge cases that I did not foresee. If the test is failing and you believe your implementation is correct, feel free to message me.

The max score for this assignment is 105%, allowing some leeway for an incomplete assignment to still score well, since this is a fairly complicated assignment.

Penalties:

§6 Extra Credit #

You can earn an additional 10% extra credit by making your program capable of ingesting “messy” data. With real datasets, it’s common to have issues or inconsistencies with the input data, sometimes you need to be able to handle edge cases.

In the file books-alt-hard.csv, an additional book with inconsistent formatting is added at the top (ID=0). The price of this book is formatted as an integer instead of a float, and the description is quote-escaped due to extra commas in the description.

If you can improve your import function to handle these edge cases, you can earn the extra credit. The extra credit is all-or-nothing. I suggest completing, committing, and syncing your regular submission, before attempting this more complex challenge. Thanks to git, you can easily change or revert your changes later, as it keeps a history of every change you commit.

To get the extra credit, be sure to let me know that your program is capable of reading books-alt-hard.csv, and also add an extra section to your write-up explaining how you went about solving this challenge.

§7 Inputs #

I have provided some input files for you to use in this lab; the examples on this document have all used books.csv as an input. You also have access to books-alt.csv as a secondary example you can test with. I will use several files like these to test that your program is functioning correctly. The books-alt-hard.csv will be discussed in the extra-credit section.

§8 Starter Code #

I have provided a main.cpp file with some starter code. This file has an example function to load data from the provided CSV files; you will need to modify the function to load the data into your chosen data structure.

The main() function is also partially started, with the sections of the test already defined for you; you just need to add your logic to each section of the main() function.

§9 Output #

The provided main.cpp as-is has the following “blank” output:

=== 1. Load the list of books from a file. ===

=== 2. Print full information of book with ID=0. ===

=== 3. Print compact form (ID, title, author, count) of book with ID=0. ===

=== 4. Update inventory count of book with ID=1 to `2`. ===

=== 5. Print the full information of book with ID=1 ===

=== 6. Print the full alphabetized list of books in compact form ===

=== 7. Print compact info of all books that cost less than $10.51 ===

=== 8. Print compact info of all books that belong to the 'Fantasy' genre ===

=== 9. Print compact info of all books written by 'J.R.R. Tolkien' AND longer than 325 pages ===

=== 10. Print compact info of all books whose titles contain the text 'and' ===

=== 11. Perform a 'sale' of the book with ID=0 ===

=== 12. Perform a 'sale' of the book: 'The Lord of the Rings: The Two Towers' ===

=== 13. Attempt two more sales of the book with ID=0, second 'sale' should fail. ===

=== 14. Print the full info of all books in alphabetical order ===

The completed project should have the following output, order does not matter in non-alphabetized sections (some completed sections will have no output):

=== 1. Load the list of books from a file. ===

=== 2. Print full information of book with ID=0. ===
Title: The Great Gatsby | Author: F. Scott Fitzgerald | ID: 0 | Price: 10.5 | Year Published: 1925 | Page Count: 180 | Genre: Fiction | Summary: A story about the mysterious Jay Gatsby and the American Dream. | Copies: 2

=== 3. Print compact form (ID, title, author, count) of book with ID=0. ===
0; The Great Gatsby; F. Scott Fitzgerald; 2

=== 4. Update inventory count of book with ID=1 to `2`. ===

=== 5. Print the full information of book with ID=1 ===
Title: To Kill a Mockingbird | Author: Harper Lee | ID: 1 | Price: 10.99 | Year Published: 1960 | Page Count: 281 | Genre: Fiction | Summary: A novel about racial injustice in the Deep South. | Copies: 2

=== 6. Print the full alphabetized list of books in compact form ===
3; 1984; George Orwell; 5
5; Brave New World; Aldous Huxley; 10
7; Crime and Punishment; Fyodor Dostoevsky; 11
4; Moby Dick; Herman Melville; 4
2; Pride and Prejudice; Jane Austen; 3
6; The Catcher in the Rye; J.D. Salinger; 3
0; The Great Gatsby; F. Scott Fitzgerald; 2
8; The Hobbit; J.R.R. Tolkien; 8
10; The Lord of the Rings: The Fellowship of the Ring; J.R.R. Tolkien; 3
12; The Lord of the Rings: The Return of the King; J.R.R. Tolkien; 5
11; The Lord of the Rings: The Two Towers; J.R.R. Tolkien; 7
1; To Kill a Mockingbird; Harper Lee; 2
9; War and Peace; Leo Tolstoy; 2

=== 7. Print compact info of all books that cost less than $10.51 ===
0; The Great Gatsby; F. Scott Fitzgerald; 2
2; Pride and Prejudice; Jane Austen; 3
3; 1984; George Orwell; 5

=== 8. Print compact info of all books that belong to the 'Fantasy' genre ===
8; The Hobbit; J.R.R. Tolkien; 8
10; The Lord of the Rings: The Fellowship of the Ring; J.R.R. Tolkien; 3
11; The Lord of the Rings: The Two Towers; J.R.R. Tolkien; 7
12; The Lord of the Rings: The Return of the King; J.R.R. Tolkien; 5

=== 9. Print compact info of all books written by 'J.R.R. Tolkien' AND longer than 325 pages ===
10; The Lord of the Rings: The Fellowship of the Ring; J.R.R. Tolkien; 3
11; The Lord of the Rings: The Two Towers; J.R.R. Tolkien; 7
12; The Lord of the Rings: The Return of the King; J.R.R. Tolkien; 5

=== 10. Print compact info of all books whose titles contain the text 'and' ===
2; Pride and Prejudice; Jane Austen; 3
7; Crime and Punishment; Fyodor Dostoevsky; 11
9; War and Peace; Leo Tolstoy; 2

=== 11. Perform a 'sale' of the book with ID=0 ===
The Great Gatsby sold.

=== 12. Perform a 'sale' of the book: 'The Lord of the Rings: The Two Towers' ===
The Lord of the Rings: The Two Towers sold.

=== 13. Attempt two more sales of the book with ID=0, second 'sale' should fail. ===
The Great Gatsby sold.
ERROR: 0 copies of book 'The Great Gatsby' available

=== 14. Print the full info of all books in alphabetical order ===
Title: 1984 | Author: George Orwell | ID: 3 | Price: 9.99 | Year Published: 1949 | Page Count: 328 | Genre: Dystopian | Summary: A dystopian story about a totalitarian regime and surveillance. | Copies: 5
Title: Brave New World | Author: Aldous Huxley | ID: 5 | Price: 11.99 | Year Published: 1932 | Page Count: 311 | Genre: Dystopian | Summary: A futuristic society controlled by technology and conditioning. | Copies: 10
Title: Crime and Punishment | Author: Fyodor Dostoevsky | ID: 7 | Price: 14.99 | Year Published: 1866 | Page Count: 671 | Genre: Philosophical Fiction | Summary: A psychological exploration of morality and guilt. | Copies: 11
Title: Moby Dick | Author: Herman Melville | ID: 4 | Price: 12.5 | Year Published: 1851 | Page Count: 635 | Genre: Adventure | Summary: The tale of Captain Ahab's obsessive quest to kill the white whale Moby Dick. | Copies: 4
Title: Pride and Prejudice | Author: Jane Austen | ID: 2 | Price: 8.99 | Year Published: 1813 | Page Count: 279 | Genre: Romance | Summary: A classic romance novel exploring themes of class and marriage. | Copies: 3
Title: The Catcher in the Rye | Author: J.D. Salinger | ID: 6 | Price: 10.99 | Year Published: 1951 | Page Count: 214 | Genre: Fiction | Summary: A story about teenage rebellion and alienation. | Copies: 3
Title: The Great Gatsby | Author: F. Scott Fitzgerald | ID: 0 | Price: 10.5 | Year Published: 1925 | Page Count: 180 | Genre: Fiction | Summary: A story about the mysterious Jay Gatsby and the American Dream. | Copies: 0
Title: The Hobbit | Author: J.R.R. Tolkien | ID: 8 | Price: 12.99 | Year Published: 1937 | Page Count: 310 | Genre: Fantasy | Summary: The adventures of Bilbo Baggins in Middle-earth. | Copies: 8
Title: The Lord of the Rings: The Fellowship of the Ring | Author: J.R.R. Tolkien | ID: 10 | Price: 13.99 | Year Published: 1954 | Page Count: 423 | Genre: Fantasy | Summary: The first part of the epic trilogy where Frodo begins his journey to destroy the One Ring. | Copies: 3
Title: The Lord of the Rings: The Return of the King | Author: J.R.R. Tolkien | ID: 12 | Price: 13.99 | Year Published: 1955 | Page Count: 416 | Genre: Fantasy | Summary: The final part of the trilogy where the fate of Middle-earth is decided. | Copies: 5
Title: The Lord of the Rings: The Two Towers | Author: J.R.R. Tolkien | ID: 11 | Price: 13.99 | Year Published: 1954 | Page Count: 352 | Genre: Fantasy | Summary: The second part of the trilogy following the separate journeys of the Fellowship members. | Copies: 6
Title: To Kill a Mockingbird | Author: Harper Lee | ID: 1 | Price: 10.99 | Year Published: 1960 | Page Count: 281 | Genre: Fiction | Summary: A novel about racial injustice in the Deep South. | Copies: 2
Title: War and Peace | Author: Leo Tolstoy | ID: 9 | Price: 18.99 | Year Published: 1869 | Page Count: 1225 | Genre: Historical Fiction | Summary: A sweeping narrative of Russian society during the Napoleonic era. | Copies: 2

§10 Help #

I want you to do well. Please message me on Canvas, email, or join office hours if you feel lost or have any questions about the assignment or your implementation.

I am happy to answer questions or provide guidance to help you succeed.

§11 Submission #

Commit and sync your code just like any other assignment in this class.

Also submit a short write-up on Canvas, details are in the next section.

Be aware that your source code will be shown to the rest of the class, as we will perform a “code review” of your project implementation.

The Due Date and the Close Date for the project are strict. This project has more time than other assignments to complete, but is also expected to take more time than other assignments.

Late work will not be accepted. Due to how long these projects take to grade, I am unable to accept resubmissions after grading in order to maintain fairness for all students.

Submit early to avoid the risk of receiving a zero due to mistakes like uploading the wrong file. I will let you know if your project submission has major issues so you have time to fix it, but you will not get an opportunity to fix it after the due date.

§12 Deliverables #