You are to implement a custom version of the linked list class that stores the data from a simple phone book.

What you must implement:
You will be implementing a linked list class named phonebook in phonebook.cpp and phonebook.h. The node for your phonebook (we'll call it entry) should store the following data (in its node struct or class):
The first_name of the entry
The last_name of the entry
The phone number of the entry
You may define the node for your phonebook class in its own .h file or in the phonebook header. You must also implement the following minimum functionality (methods):
A default constructor/destructor phonebook and phonebook
push_front and push_back methods
read_from_file - takes a string file name as a parameter and reads the phonebook from the file with that name
write_to_file - takes a string with a file name as a parameter and writes the phonebook to the file with that name
insert_sorted - We have implemented insertion at the head and tail in class, however linked lists allow for easy reorganization anywhere in the list. Much like the remove method, you should search for an insertion point in the list by traversing the list, insert a new node in the middle of the list in alphabetical order, sorted by the user's last name.
lookup - takes a name as a parameter and returns the number associated with it
reverse_lookup - takes a phone number as a parameter and returns the name of the individual associated with it.
print - prints the content of the directory to the screen (I'm leaving the formatting up to you but I expect the data to be labeled and formatted).
delete_user - takes a user's name as a parameter (or parameters) and removes their entry from the phonebook.
Note: In general your methods should not be doing input/output with the user directly. You should interact with the user in the main() and pass information to your methods using parameters.

Data File Format
You should provide a data file for testing purposes. Your program should read and write the same file format (i.e., the file output of your program should be able to serve as your program's input). The format is as follows:
first_name1 last_name1
first_name2 last_name2
Where each entry has an appropriate value (e.g., first_namei may be John last_namei may be Doe and phone_numberi may be (731) 555-3245).

As your program reads the file you should use insert_sorted to store the data in order (i.e., an unsorted file should get sorted by your program).

You are not being provided with a driver. Instead, you are asked to implement a driver that manages interaction with the user as well as the interaction with your simple linked list-based database. The driver should have a loop that gives the user the following choices:
Welcome to the UTM Phonebook! You may select one of the following options:
1 Read a phonebook from a file
2 Write the phonebook to a file
3 Print the phonebook
4 Search for a user's phone number
5 Reverse lookup by phone number
6 Add a user
7 Delete a user
8 Exit this program

Please enter your choice now: [user enters their choice here]
Note that this implies the use of a loop in your main() that allows the user to keep selecting from the list until they are done. Also note that your method behavior should be consistent, and should prevent against simple errors: printing an empty database to a file should result in an empty file, your program should be able to read back in a database that it has written to a file, etc.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include <cstdlib>
#include "library.h"
using namespace std;

void printMenu();

int main(int argc, char** argv) {
    library lib;
    int selection = 0;
    string fileName;
    string Title;// - (string) May include spaces.
    string Author; // (string) May include spaces.
    int Pages; // - (int) The number of pages.
    string isbn; // - (string)
    float price; // (float)
    int Year; // (int or short)
    book b;
    while (selection != 7) {
$30.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats