Assignment 6: A Linked List with a Tail Pointer (individual)
Due: 11/12 at 11:59 p.m.
Libraries You May Use
You are to implement a custom version of the linked list class with both
a head pointer and a tail pointer that stores the information of a list of
What you must implement:
You will be implementing a linked list class named employeelist in
employeelist.cpp and employeelist.h
head and tail pointers.
The node for an employee (we'll call it entry) should store the following data (in its node struct or class):
You may define the node for your
employeelist class in its own .h file or in the employeelist header.
You should include a head
pointer and a
tail pointer for a linked list. You must also implement the following minimum functionality (methods):
- The first_name of the entry
- The last_name of the entry
- The salary of the entry
Note: In general your methods should not be interacting with the user
directly by doing input/output from/to the user. Instead, your methods should
pass information to the main() method and leave input/output to the main()
- A default constructor/destructor employeelist and ~employeelist
insert from the front of the list via head
- push_back methods:
insert from the tail of the list via tail
- read_from_file - takes a string file name as a parameter and
reads the employees from the file with that name
- write_to_file - takes a string with a file name as a parameter
and writes the employees to the file with that name
- insert_sorted - We have implemented insertion at the head and
at the tail, 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
employee's last name.
- lookup - takes a name as a parameter and returns the
salary associated with it.
- reverse_lookup - takes
min and max
to define a range of salaries and returns the names of the employees whose
salaries are within the range.
- print - prints the content of the list to the screen (I'm leaving the formatting up to you but I expect the data to be labeled and formatted).
- delete_employee - takes a employee's name as a parameter (or
parameters) and removes their entry from the employeelist.
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:
Where each entry has an appropriate value (e.g., first_namei may be John, last_namei may be Doe, and
salaryi may be 3245.46.
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).
Your program's documentation should be consistent with previous assignments (see previous assignments and examples for more information).
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! You may select one of the following options:
1 Read an employee list from a file
2 Write the employee list to a file
3 Print the employee list
4 Search for an employee's salary
5 Reverse lookup by a salary range
6 Add an employee
7 Delete an employee
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.
What you must turn in.
Electronically a single zip file, with the name LASTNAME_FIRSTNAME.zip.
Your zip file should extract into a directory with the same name as the zip (please make sure to put your files in a separate directory before submission). Your zip should include all files necessary to compile and run your program including:
- main.cpp - Should implement your main file, include other files.
- employeelist.h - The definition for the employeelist class.
- employeelist.cpp - The method definitions for the
- employeelist.txt - A sample employee list file that can be read from and written by your program.
- Any other source files or ASCII data files required to test your program.
- Please do not turn in object or executable code.
Note: Your program must compile and run on CS1 (or a UD lab machine) or it will not be graded. Please see the syllabus for details.