Kat H.

asked • 07/01/21

C++. Collection App with structs

Introduction


Write in C++ at the Linux command line a collection program that keeps track of a collection of information. You can come up with your own idea of what information to store in the collection. Whatever idea you come up with, it must be complex enough to require an array of structs with at least three fields. See requirements for more details.

Some ideas for collections are:


  1. movie collection
  2. book collection
  3. video game collection
  4. todo list
  5. DnD possessions (weapons, treasure, etc.) list.

Note: Your project's idea should be different from any example code I provide or the textbook provides.


I have an output example of a book collection manager below. This shows the level of complexity that your own program should have to get full credit. If are unsure on what to do, you can use this as your project's theme.


Whatever you do, 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.


Also make sure you keep the source code when you are done as you will need to use it for the rest of project assessments.


REQUIREMENTS


PLEASE SEE THE GENERAL REQUIREMENTS FOR FURTHER REQUIREMENTS NEEDED. BELOW IS NOT ALL THE REQUIREMENTS NEEDED IN YOUR CODE.


The following are in addition to the above general requirements


Tasks


Your program should have as a minimum the following tasks:


1. Allow the user to add entries to the collection. Check for valid data and let the user re-enter if they enter invalid data. Please let the user know what is valid data. For example, if the program needs a number between 1 and 100 let the user know in the prompt that they need to enter a number between 1 and 100.


So what is invalid data? I'm letting students define that but at a minimum whatever a user inputs should NOT cause your program to malfunction or crash (ie get a run-time error). So at least check for input that might cause your program not run correctly or crash. However, it doesn't hurt to catch obvious invalid data (e.g. negative years or prices) so the user can re-type them. if you want to you can ask the user if the data entered is okay and then allow them to re-enter.


2. Allow the user to print out the entire collection. Should not print out blank entries or invalid entries.


3. Allow the user to delete an entry from the collection. Allow users to choose which entry to delete. This can be by index (do print out the entries with their indices so the user can know what entry goes with what index). OR you can let them enter a search value and then search for that entry. If the entry is not found, do print out an error message, don't just do nothing. You can ask the user to re-enter or you can just return to the main function. Also, if you are using an index into the array, make sure this is a valid index to valid data.


Other tasks can be added but only if the above tasks are also present and working correctly. However, 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 code structures:


1. An array of structs. The struct needs to be defined with at least 3 fields. At least one field should be numeric (integer or floating point) and at least one field should be a C string type (no C++ string type please). Please no parallel arrays (more than one array of simple types) for storing the collection.


2. A header file with your struct definition in it. Name the file after your struct name in all lower-case letters to prevent case-conflict issues.


3. Need to have at least one separate function for each task. Please try to break up your function tasks into smaller functions if they are getting long. Remember there is a 30 line requirement for all functions including the main function.


4. No global variables or goto's. See C++ Coding Guidelines under the Course Information module for styling and comment requirements.


Example Output


This is an example output from a program I wrote. This is just to show what level of coding I want your program to be for full credit. If you want to, you can write your program to do basically what this program does.


NOTE: Don't just code your program to print out what is below; I will NOT be using the same input values when running your program.


*** BOOK COLLECTION ***

== Main Menu ==

1 -> add books to the collection

2 -> print all books

3 -> delete a book from the collection

4 -> quit the program

Please enter a choice (1 to 4)

1

enter title?

The Name Of The Wind

enter author?

Patrick Roth

enter year? (year should be larger than 0) 2007

Do you want to continue? ('y' or 'n')

y


1 Expert Answer

By:

Patrick B. answered • 07/02/21

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.