PA 5.2: Digital Rolodex
- Due Mar 30, 2021 by 11:59pm
- Points 10
- Submitting a file upload
- File Types cpp
- Available after Mar 16, 2021 at 2pm
When completing this programming assignment, you may work with up to one other person. No groups of more than two are permitted.
In class, we started to develop a program for keeping track of a list of contacts in two parallel vectors—one to hold the contacts' names, the other to hold contacts' phone numbers. For this programming assignment, you will implement and extend that problem so that it includes the following menu options (changes in bold green):
- add a contact
- prompts the user for the new contact's name, phone number, and email address and add that information to the end of the respective vector
- list all contacts
- prints all of the contacts (name, phone number, and email of each) entered so far; include the index (not the position) of each contact in the contacts vector—the user will need the index when removing a contact
- if there are no contacts, say so
- remove a contact
- asks the user for the index of the contact, then removes the information at that index from the three vectors
- this should be done using a loop (not a built in function)
- if the index if invalid (outside the range of the vectors), say so and continue on with the menu loop
- search contacts by name
- asks the user for the search phrase, then displays only contacts whose name includes the search phrase
- e.g., the search phrase "Smith" would match contacts with the name "Joe Smith" and "Pat Smith"
- if there are no matches, the program says "No matches found"
- quit the program
Here's a run of a program that meets these criteria (your output doesn't have to look exactly the same as long as it has the same information and your formatting is good). User input is shown in bold orange.
$ ./rolodex ==== Digital Rolodex ==== Select an option: [a]dd contact [l]ist contacts [r]emove contact [f]ind contact [q]uit > a Enter contact's name: Pat Smith Enter contact's phone number: 111-111-1111 Enter contact's email: psmith@mail.com Contact added! Select an option: [a]dd contact [l]ist contacts [r]emove contact [f]ind contact [q]uit > a Enter contact's name: Bob Jones Enter contact's phone number: 222-222-2222 Enter contact's email: bjones@mail.com Contact added! Select an option: [a]dd contact [l]ist contacts [r]emove contact [f]ind contact [q]uit > l Contacts: [0] Pat Smith <psmith@mail.com> (111-111-1111) [1] Bob Jones <bjones@mail.com> (222-222-2222) Select an option: [a]dd contact [l]ist contacts [r]emove contact [f]ind contact [q]uit > f Enter a name or part of a name (all partial matches will be listed): smith No matches found. Select an option: [a]dd contact [l]ist contacts [r]emove contact [f]ind contact [q]uit > f Enter a name or part of a name (all partial matches will be listed): Smith Matches: [0] Pat Smith <psmith@mail.com> (111-111-1111) Select an option: [a]dd contact [l]ist contacts [r]emove contact [f]ind contact [q]uit > r Enter the index of the contact to remove: 2 That index isn't valid. Select an option: [a]dd contact [l]ist contacts [r]emove contact [f]ind contact [q]uit > r Enter the index of the contact to remove: 0 Pat Smith successfully removed. Select an option: [a]dd contact [l]ist contacts [r]emove contact [f]ind contact [q]uit > l Contacts: [0] Bob Jones <bjones@mail.com> (222-222-2222) > q Bye!
Copy the following header and specifications checklist and paste it at the top of your source code. As you complete the specifications, fill in the [ ] next to that specification in the check list (e.g., like this: [x]). I will not grade submissions with missing specifications; please do not submit if you cannot check all of them off. This specs checklist is essentially a way for you to self grade before you submit your program.
// Name:
// Date:
// Partner:
//
// Specifications checklist for PA 5.2 Digital Rolodex
//
// General specs:
// [ ] the header includes your name and anyone you worked with
// [ ] the header includes this specifications checklist with all completed
// specifications checked off: [x]
// [ ] the code is indented properly (inside of every block, code is indented
// one more tab)
// [ ] each chunk of code that "hangs together" (works toward a higher level goal):
// [ ] includes a brief, useful comment above it
// [ ] is separated from the next chunk by a blank line
// [ ] there are no really long lines of code or comments (if you have long
// lines, split them across multiple shorter lines)
// [ ] identifiers are well named
// [ ] the program compiles
// [ ] the program runs without crashing or hanging
// [ ] all output and prompts look clean (correct spelling, capitalization,
// nothing squished)
// [ ] all prompts make it clear what data the user is expected to enter and in
// what format and work as expected
//
// Specific specs:
// [ ] the user is presented with a menu with the options: add, list, remove, search, and quit
// [ ] if the user selects add they are prompted to enter each piece of information (name, phone number, email)
// [ ] if the user selects search, they are prompted to enter a search phrase and the contacts whose
// name contains the search phrase are displayed along with their indexes in the vectors
// [ ] if the user selects to list contacts, all contacts are displayed with their indexes
// [ ] if no contacts are present, a message saying as much is displayed
// [ ] if the user selects to remove a contact, they are prompted to enter the index of the contact
// to remove and that contact is removed from the vector by shifting every contact after the delete
// contact down one position in the vector and resizing the vector
// [ ] if the index is invalid (out of range of the vectors), an error message is displayed an
// the user is returned to the menu
// [ ] if the user select quit, the program ends
// [ ] the menu is shown again after processing the previous selection until they select to quit
If you are working with a partner, both of you must submit individually.