Phone book application THIS IS A C++ PROJECT Description In this assignment (HW4), you will implement a program that verifies the format of a list of phone numbers and prints the list in alphabetical...


Phone book application THIS IS A C++ PROJECT Description In this assignment (HW4), you will implement a program that verifies the format of a list of phone numbers and prints the list in alphabetical order. Phone book program specification


The phone book program will read a list of names and phone numbers from a phone list file. The name of the phone list file will be given as a command line argument. The program will read entries from the phone list file and check that they conform to the format described below. It will print error messages and exit if the entries do not follow the expected format. If no format errors are found, it will print the phone list on standard output in alphabetical order by last name and first name, i.e. in such a way that entries are sorted by first name if last names are the same. Phone list format a phone list file consists of one record per line. Each line consists of three tokens: a last name followed by a first name, followed by a phone number written in the format ddd-ddd-dddd where d is a digit in [0-9]. These three tokens are separated by one or more white spaces. The first name and last name tokens should consist of characters in the set [a-zA-Z]. It can be assumed that each line in the phone list file will contain three tokens. However, first names, last names and numbers may be incorrectly formatted. Error conditions the following error conditions must be detected and reported by the phone book program: Missing phone list file if the file given as a command line argument is missing, the program should print File not found and exit. Invalid characters in the last name if the last name contains characters that are not in [a-zA-Z], the program should print Invalid characters in last name and exit. Invalid characters in the first nameif the first name contains characters that are not in [a-zA-Z], the program should print Invalid characters in first name and exit. Invalid number format If the phone number does not conform to the format “ddd-ddd-dddd” where d is a digit in [0, 9], the program should print invalid number format and exit. Duplicate entries


If an entry in the phone list has the same first name and last name as a previous entry, it should be ignored (even if the phone number is different). The above error messages should be printed on stout. Do not use stderr.Implementation the program must use a class Person that encapsulates the last name, first name and phone number of a person. The file Person’s is provided and should not be modified. Use the is alpha and is digit functions in the implementation of the constructor of the Person class to check that the first and last names consist of characters in [a-zA-Z] and that the number contains digits and the character ’-’ in the appropriate places. The program should use the STL set container to store instances of persons. Use the property of the set container that elements are automatically sorted as they are inserted. You will have to define operator<> #include class Person {public:


Person(std::string last, std::string first, std::string num); std::string lastName(void) const; std::string firstName(void) const; std::string number(void) const; bool operator<(const><>


May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here