Starting from:

$25

CS3100/5100: Data Structures and Algorithms Programming Assignment #2

1. Project Description

For this assignment, you will implement a stack for storing and retrieving employee records using a Singly Linked List. You should begin by creating class Employee, which will contain information about a single employee (see below). Then you will implement a Singly Linked List based Stack, in which each linked list node stores an Employee record. An Employee record inside a linked list node should support the following fields: Last Name (string), First Name (string) and Employee ID (integer). I will provide a data file that contains lines with three items: Last Name, First Name and Employee ID. Last Name, First Name and Employee ID are separated by spaces. The valid Employee ID is a number from 0 - 9999999.

A stack is a container of objects that are inserted and removed according to the last-in-first-out principle. The header file SStack.h will be provided to you. SStack.h is the header file that specifies the interface of the abstract data type Singly Linked List based Stack that you need to implement. You must implement all the functions in SStack.h.

To test the Singly Linked List based Stack, a small employee database with many employee records is provided to you. In the beginning of your main() function, you should open the input file, and then create a Singly Linked List based Stack: Then read a specified number (for example, 100) of the employee records from the input file, and push these employee records onto the stack. After you pushed the employee records onto the stack, you should test ALL the other functions in SStack.h. You should print out a message describing the operation you tested.

Then in your main() function, you will provide a user interface (MENU) to test the member functions of the stack ADT and to support the following operations.

1. Push: prompt user for all fields, create an employee record and push it onto the top of the stack, then print the number of the elements in the stack, and also the top 5 elements in the stack to the screen if the number of elements in the stack is larger than 5.

2. Pop: prompt user for a number, and if the number of the elements in the stack is larger than the number entered by the user, pop the specified number of the elements from the stack, and print the employee records popped from the stack, and the remaining number of the elements in the stack to the screen. Otherwise, pop all the elements from the stack.

3.Top: print the employee record on the top of the stack and the remaining number of the elements in the stack to the screen.


4. Print: Print all the elements in the stack onto the screen.

5.Save: save all the elements in a stack to a file on the disk.

6. Quit: clear all the elements in the stack, so there is no memory leak in your program, and quit.



2. Requirements

The main.cpp file includes code that will test the implementation of your member functions of your Stack ADT.

1). In SStack.cpp, you must implement all the functions in SStack.h.

2). Your code should follow the Code Standards posted on Pilot. Your code will be graded according to its correctness, efficiency, organization, and readability.

3). Make sure that each file includes your name and email address in the header comments.

More products