C++ Program 8 & More

profiletheman04
program_8_c.zip

Program 8 C++/newproblems.txt

123 3 3/14/2013 Kristin Brewer
103 2 8/23/2013 Marcia Stephenson
122 2 8/28/2013 Jeremy Savage
115 1 9/4/2013 Alfred Reddy
109 1 9/20/2013 Justin Liu
117 3 4/22/2013 Francis Wheeler
111 1 4/25/2013 Jeremy Chung
119 3 4/26/2013 Monica Fuller
111 2 5/1/2013 Clara Graves
105 3 5/3/2013 Dorothy Cox
111 3 5/8/2013 Bryan McCall
102 1 5/13/2013 Lorraine Te
107 2 10/7/2013 Andrea Braun
110 2 10/8/2013 Debbie Britt
124 2 10/9/2013 Wanda Ennis
118 2 10/11/2013 Tammy Grant
120 3 10/15/2013 Dorothy Flowers
116 1 10/16/2013 Christine Bullardrrell

Program 8 C++/orderLinkedList.h

//********************************************* // The ListNode class creates a type used to * // store a node of the linked list. * // PRECONDITIONS: * // Choice for ItemType implements 'cout' * // as well as "==" and "<" operators * //********************************************* #ifndef OrderOrderLinkedList_H #define OrderOrderLinkedList_H template <class ItemType> class ListNode { public: ItemType info; // Node value ListNode<ItemType> *next; // Pointer to the next node // Constructor ListNode (ItemType nodeValue) { info = nodeValue; next = NULL; } }; //********************************************* // OrderLinkedList class * //********************************************* template <class ItemType> class OrderLinkedList { private: ListNode<ItemType> *head; // List head pointer ListNode<ItemType> *currentPos; // Pointer to "current" list item int length; // Length public: OrderLinkedList(); // Constructor ~OrderLinkedList(); // Destructor OrderLinkedList( const OrderLinkedList<ItemType>& anotherList ); // Copy constructor void operator= ( const OrderLinkedList<ItemType>& ); // Assignment op void insertNode(ItemType); void deleteNode(ItemType); bool searchList(ItemType& item); int getLength(); void displayList(); void resetList(); ItemType getNextItem(); // Iterator bool atEnd(); }; //************************************************** // Constructor * // Initial list head pointer and length * //************************************************** template <class ItemType> OrderLinkedList<ItemType>::OrderLinkedList() { head = NULL; length = 0; } //************************************************** // displayList shows the value stored in each node * // of the linked list pointed to by head. * // Precondition: "cout" operator enabled for * // ItemType data type. * //************************************************** template <class ItemType> void OrderLinkedList<ItemType>::displayList() { ListNode<ItemType> *nodePtr; nodePtr = head; while (nodePtr != NULL) { cout << nodePtr->info << endl; nodePtr = nodePtr->next; } } //************************************************** // The insertNode function inserts a node with * // newValue copied to its value member. * //************************************************** template <class ItemType> void OrderLinkedList<ItemType>::insertNode(ItemType newValue) { ListNode<ItemType> *newNode, *nodePtr, *previousNode = NULL; // Allocate a new node & store newValue newNode = new ListNode<ItemType>(newValue); // If there are no nodes in the list // make newNode the first node if (head == NULL) { head = newNode; newNode->next = NULL; } else // Otherwise, insert newNode { // Initialize nodePtr to head of list and previousNode to NULL. nodePtr = head; previousNode = NULL; // Skip all nodes whose value member is less // than newValue. while (nodePtr != NULL && nodePtr->info < newValue) { previousNode = nodePtr; nodePtr = nodePtr->next; } // If the new node is to be the 1st in the list, // insert it before all other nodes. if (previousNode == NULL) { head = newNode; newNode->next = nodePtr; } else // Otherwise, insert it after the prev. node. { previousNode->next = newNode; newNode->next = nodePtr; } } } //***************************************************** // The deleteNode function searches for a node * // with searchValue as its value. The node, if found, * // is deleted from the list and from memory. * //***************************************************** template <class ItemType> void OrderLinkedList<ItemType>::deleteNode(ItemType searchValue) { ListNode<ItemType> *nodePtr, *previousNode; // If the list is empty, do nothing. if (!head) return; // Determine if the first node is the one. if (head->info == searchValue) { nodePtr = head->next; delete head; head = nodePtr; } else { // Initialize nodePtr to head of list nodePtr = head; // Skip all nodes whose value member is // not equal to searchValue. while (nodePtr != NULL && nodePtr->info != searchValue) { previousNode = nodePtr; nodePtr = nodePtr->next; } // If nodePtr is not at the end of the list, // link the previous node to the node after // nodePtr, then delete nodePtr. if (nodePtr) { previousNode->next = nodePtr->next; delete nodePtr; } } length--; } //************************************************** // Linear search * // Post: If found, item's key matches an element's * // key in the list and a copy of that element has * // been stored in item; otherwise, item is * // unchanged. Return value is boolean to indicate * // status of search. * //************************************************** template <class ItemType> bool OrderLinkedList<ItemType>::searchList(ItemType& item) { bool moreToSearch; ListNode<ItemType>* nodePtr; nodePtr = head; // Start search from head of list bool found = false; // Assume value not found moreToSearch = (nodePtr != NULL); while (moreToSearch && !found) { if (nodePtr->info < item) { nodePtr = nodePtr->next; moreToSearch = (nodePtr != NULL); } else if (item == nodePtr->info) { found = true; item = nodePtr->info; } else moreToSearch = false; } return found; } //************************************************** // Iterator reset function * // Resets pointer of current item in list to the * // head of the list. * //************************************************** template <class ItemType> void OrderLinkedList<ItemType>::resetList() // Post: Current position has been initialized. { currentPos = head; } //************************************************** // Function: Gets the next element in list as // referenced by currPtr // Pre: Current position is defined. // Element at current position is not last in list. // Post: Current position is updated to next position. // item is a copy of element at current position. //************************************************** template <class ItemType> ItemType OrderLinkedList<ItemType>::getNextItem() { ItemType item; if (currentPos == NULL) currentPos = head; // wrap if getnext is called at past-end //else item = currentPos->info; currentPos = currentPos->next; return item; } //************************************************** // Observer function to return current list length * //************************************************** template <class ItemType> int OrderLinkedList<ItemType>::getLength() { return length; } //************************************************** // Observer function to determine if current * // is the end of the list * //************************************************** template <class ItemType> bool OrderLinkedList<ItemType>::atEnd() { if (currentPos == NULL) return true; else return false; } //************************************************** // Copy Constructor * //************************************************** template<class ItemType> OrderLinkedList<ItemType>::OrderLinkedList( const OrderLinkedList<ItemType>& anotherList ) { ListNode<ItemType>* ptr1; ListNode<ItemType>* ptr2; if (anotherList.head == NULL) head = NULL; else { head = new ListNode<ItemType>(anotherList.head->info); ptr1 = anotherList.head->next; ptr2 = head; while (ptr1 != NULL) { ptr2->next = new ListNode<ItemType>(ptr1->info); ptr2 = ptr2->next; ptr1 = ptr1->next; } ptr2->next = NULL; } length = anotherList.length; } //************************************************** // Overloaded Assignment Operator * //************************************************** template<class ItemType> void OrderLinkedList<ItemType>::operator=( const OrderLinkedList<ItemType>& anotherList ) { ListNode<ItemType>* ptr1; ListNode<ItemType>* ptr2; if (anotherList.head == NULL) head = NULL; else { head = new ListNode<ItemType>(anotherList.head->info); ptr1 = anotherList.head->next; ptr2 = head; while (ptr1 != NULL) { ptr2->next = new ListNode<ItemType>(ptr1->info); ptr2 = ptr2->next; ptr1 = ptr1->next; } ptr2->next = NULL; } length = anotherList.length; } //************************************************** // Destructor * // This function deletes every node in the list. * //************************************************** template <class ItemType> OrderLinkedList<ItemType>::~OrderLinkedList() { ListNode<ItemType> *nodePtr, *nextNode; nodePtr = head; while (nodePtr != NULL) { nextNode = nodePtr->next; delete nodePtr; nodePtr = nextNode; } } #endif

Program 8 C++/problemlist.txt

100-Forgot password 101-Hard drive crash 102-Lost data 103-Frozen machine 104-File will not print 105-Network cable tip broken 106-New software won't install 107-Computer running especially slow 108-New software crashes 109-Keyboard keys too dirty to work 110-Email application missing 111-Email inbox full 112-Web browser won't open web address 113-Will not turn on 114-Burning wire smell 115-Slow network 116-Fried computer 117-Hard drive not storing files 118-Too much spam 119-Fist damange to monitor 120-New virus detected 121-Boot up takes too long 122-Printer driver out of 123-Dropped laptop 124-USB port dead 125-Monitor broken 126-Need USB cable

Program 8 C++/problems.txt

126 2 6/11/2013 Dorothy Bowman
113 2 6/13/2013 Johnny Bynum
122 3 7/15/2013 Neil Gold
104 2 8/30/2013 Edwin Nolan
110 3 9/6/2013 Kathleen Frye
119 2 9/12/2013 Elisabeth Stallings
121 1 9/16/2013 Terry Camp
102 1 9/17/2013 Tracy Hwang
109 2 9/20/2013 Regina Langley
112 2 9/25/2013 Barry Guthrie
118 2 9/27/2013 William Barry
104 1 10/1/2013 Connie Duffy
103 1 10/3/2013 Bruce McGuire
116 2 7/16/2013 Erica Long
116 2 9/11/2013 Lucille Sellers
120 2 10/21/2013 Gladys Starr
103 1 11/22/2013 Kent Malone
104 2 11/26/2013 Vernon Adcock
117 3 12/11/2013 Marilyn Hanna
107 2 12/30/2013 John Stanton
116 3 4/4/2013 Marshall Garrison
117 2 6/18/2013 Theresa Tyson
109 1 8/12/2013 Mitchell Manning
119 2 11/28/2013 Roberta Horner
116 3 12/18/2013 Dianne Strickland
112 2 12/26/2013 Victor Sanford
110 1 3/13/2013 Stephanie Winstead
123 1 3/18/2013 Ian Blanton
106 1 3/21/2013 Tim Frank
103 1 3/22/2013 Philip Tuttle
115 2 3/26/2013 Peter Pittman
106 2 3/29/2013 Jackie Cook
116 3 4/3/2013 Arlene McLeod
126 2 4/5/2013 Cameron Shannon
110 3 4/10/2013 Theresa Stephenson
112 1 4/11/2013 Wayne Fitzpatrick
124 1 4/12/2013 Danielle Kaufman
121 3 4/15/2013 Chris Chan
120 1 4/16/2013 Ryan Watts
120 3 4/17/2013 Karen Hines
123 3 4/18/2013 Penny Tyler
106 3 4/19/2013 Calvin Perkins
119 2 4/24/2013 Louis Boyle
122 2 4/26/2013 Harriet Elmore
114 3 4/30/2013 Randall Lutz
112 1 5/2/2013 Rodney Berry
116 3 5/6/2013 Gretchen Bridges
109 2 5/8/2013 Jim Hurley
119 1 5/9/2013 Doris Kim
103 3 5/14/2013 Julian Knox
117 3 5/15/2013 Kristine Garner
104 1 5/22/2013 Laurie McNeill
104 3 5/24/2013 Colleen Pace
113 2 5/27/2013 Frank Hull
110 2 5/29/2013 Albert Spears
126 3 5/30/2013 Christian Orr
120 2 6/4/2013 Dwight Sherrill
120 2 6/6/2013 Beth Howe
125 1 6/14/2013 Stacy Jernigan
125 3 6/17/2013 Sally Rose
101 1 6/20/2013 Michael Nichols
106 2 6/21/2013 Elaine Benson
109 2 6/26/2013 Gordon Newton
106 3 7/1/2013 Alvin Meadows
122 1 7/8/2013 Hilda Boyle
123 2 7/9/2013 Jordan Hernandez
105 1 7/10/2013 Priscilla Wu
108 1 7/15/2013 Penny Lawson
101 2 7/17/2013 Allison Lindsay
115 2 7/18/2013 Natalie Riddle
115 2 7/19/2013 Jeffrey Bates
106 3 7/22/2013 Tommy Kidd
123 2 7/25/2013 Erika Ho
117 1 7/31/2013 Kate Brooks
115 2 8/2/2013 Irene White
112 1 8/5/2013 Arlene Best
112 3 8/9/2013 Teresa Dudley
116 3 8/12/2013 Angela Starr
126 1 8/14/2013 Carlos Spencer
104 1 8/15/2013 Tamara Hamilton
122 3 8/16/2013 Kathy Poole
114 2 8/19/2013 Carmen Hartman
107 2 8/20/2013 Kathy West
120 1 9/3/2013 Tamara Shah
105 3 9/5/2013 Randall Klein
101 3 9/6/2013 Vicki Parrish
102 3 9/9/2013 Ann Clayton
118 1 9/10/2013 Jason Frank
106 2 9/16/2013 Ricky McMillan
104 1 9/18/2013 Joy Howard
118 2 9/20/2013 Ray Gibbs
117 3 9/25/2013 Norma Hatcher
126 2 9/27/2013 Sandy O'Neill
119 2 9/30/2013 Donald Anthony
126 3 10/1/2013 Howard Blum
124 2 10/2/2013 Dana Faulkner
106 2 10/8/2013 Derek Langley
105 1 10/9/2013 Colleen Hart
119 3 10/11/2013 Don Ayers
124 3 10/15/2013 Karen Rubin
115 2 10/17/2013 Gary McCormick
122 3 10/23/2013 Christopher Kaplan
119 2 10/25/2013 Carrie McNamara
123 2 10/30/2013 Jason Glass
105 3 11/1/2013 Clifford Wooten
111 2 11/6/2013 Lynne Daly
116 2 11/7/2013 Milton Pate
108 1 11/14/2013 Jeremy McDonald
114 3 11/19/2013 Harvey Bowling
103 3 11/21/2013 Neil Dickens
123 1 11/25/2013 Billy Li
111 2 11/27/2013 Pauline Tuttle
121 1 11/28/2013 Claudia Sims
118 2 11/29/2013 Jeanne O'Connor
123 1 12/3/2013 Wesley Starr
116 2 12/5/2013 Lori Stafford
125 1 12/9/2013 Larry Pope
111 1 12/13/2013 Randy Solomon
120 1 12/16/2013 Denise Hendrix
101 3 12/17/2013 Mike McKenna
104 3 12/18/2013 Erica Wong
123 2 12/19/2013 Milton Arnold
107 3 12/20/2013 Katie Noble
112 3 12/23/2013 Jean Williford
124 3 12/31/2013 Allen Baird
126 2 3/12/2013 Justin Bond
113 3 3/20/2013 Jeanne Spencer
118 1 3/21/2013 Mike Shields
126 3 3/26/2013 Sheila Craig
126 1 3/28/2013 Jack Winstead
109 2 3/29/2013 Mike Dodson
118 3 4/1/2013 Gail Glover
119 3 4/5/2013 Phillip Hawley
112 2 4/10/2013 Sara Schaefer
123 3 4/12/2013 Paige Kane
116 2 4/19/2013 Fred Wilder
121 3 5/15/2013 Kevin Reid
111 2 5/16/2013 Holly Koch
117 2 5/17/2013 Karen Kennedy
112 1 5/20/2013 Bryan Woodard
108 2 5/24/2013 Bob Sutton
118 2 5/28/2013 Paula West
107 2 5/29/2013 Brandon Oakley
119 1 5/30/2013 Kate Strickland
119 2 5/31/2013 Veronica Day
107 3 6/5/2013 Angela Brandon
110 3 6/12/2013 Wanda Byrne
124 3 6/17/2013 Terri Carver
117 3 6/19/2013 Fred Rich
117 2 6/21/2013 Hilda Singh
108 3 6/24/2013 Tracey Reilly
121 3 6/26/2013 Rhonda Boyle
114 2 7/1/2013 Kim Abrams
124 1 7/2/2013 Ruth Higgins
109 1 7/3/2013 Cynthia Richards
118 3 7/16/2013 Oscar Bernstein
107 2 7/17/2013 Vicki Sherman
119 2 7/22/2013 Lloyd Hale
113 1 7/25/2013 Sue Hudson
126 2 7/26/2013 Benjamin Moody
112 1 7/29/2013 Sidney Schultz
124 2 7/30/2013 Jesse Hinson
125 3 7/31/2013 Kate Peck
124 3 8/2/2013 Rachel Cross
102 1 8/6/2013 Stuart Snyder
117 1 8/9/2013 Arlene Blanton
106 1 8/15/2013 Gretchen Larson
123 2 8/19/2013 Michael Abrams
122 3 8/20/2013 William Freedman
126 3 8/28/2013 Jay Burnette
102 2 10/18/2013 Randy Sykes
125 3 10/23/2013 Ruth Manning
112 3 10/25/2013 Dennis Osborne
126 3 10/29/2013 Geraldine Yu
101 3 11/4/2013 Joel Winstead
122 3 11/6/2013 Eddie Moore
112 1 11/8/2013 Tony Scarborough
123 2 11/11/2013 Angela Quinn
121 1 11/13/2013 Troy Gould
120 3 11/14/2013 Marcus Forbes
102 2 11/15/2013 Terry Finch
115 3 11/18/2013 Marshall White
103 3 11/19/2013 Stacey Harmon
113 3 11/20/2013 Dawn Newton
117 3 11/22/2013 Erik Young
117 3 11/25/2013 Betty Fleming
116 1 11/27/2013 Lisa Hobbs
102 3 11/29/2013 Vicki Carlton
115 1 12/3/2013 Sidney Epstein
118 1 12/4/2013 Nancy Braswell
113 3 12/9/2013 Carl Pace
101 2 12/11/2013 Lester Bates
123 2 12/12/2013 Dan Moser
108 1 12/13/2013 Leroy Glass
107 3 12/16/2013 Julian Britt
113 3 12/18/2013 Kathleen Hodges
107 2 12/19/2013 Elsie Perkins
106 1 12/20/2013 Jennifer Bynum
123 1 12/25/2013 Dana Kent
102 2 12/26/2013 Alex Beard
111 2 12/27/2013 Leslie Paul
115 3 12/30/2013 Lindsay McPherson

Program 8 C++/resolvedproblems.txt

117 3 11/25/2013 Betty Fleming
115 3 11/18/2013 Marshall White
120 1 12/16/2013 Denise Hendrix
119 2 10/25/2013 Carrie McNamara
126 1 8/14/2013 Carlos Spencer
104 1 8/15/2013 Tamara Hamilton
125 1 6/14/2013 Stacy Jernigan
116 3 12/18/2013 Dianne Strickland
126 2 4/5/2013 Cameron Shannon
119 1 5/9/2013 Doris Kim
123 3 4/18/2013 Penny Tyler
115 3 12/30/2013 Lindsay McPherson
101 2 12/11/2013 Lester Bates
123 2 11/11/2013 Angela Quinn

Program 8 C++/What to do for Program 8.docx

Purpose

This program will provide an opportunity to build an application that utilizes a linked list data structure.

Specifications

Write a program to manage a list of computer-related problems for a help desk application. This will be a file-driven program that involves addition to and deletion from a linked list of "problem" objects.

Create a class to store one Problem. Data members should include:

· Problem Code (a code definiting the type of problem)

· Criticality (a 1...5 integer designation of the level of importance of the problem: highest: 1, lowest 5)

· Date (a calendar date object using the provided class used in the course)

· Contact (string containing name of person initiating problem)

Three files of problems are included for this solution. The file format is:

117,3,12/11/2013,Marilyn,Hanna

defined by

problemcode,criticality,month/day/year,firstname,lastname

Assume scenario that includes a current list of problems, a list of problems recently solved, and a third list of new problems not yet tasked. The three files are:

problems.txt newproblems.txt resolvedproblems.txt

In addition, a file is provided that allows the problem code to be decyphered to a specific problem description:

problemlist.txt

Define a class (assume named ProblemList) that has-a ordered linked list of Problem objects as a member (bad grammar intentional). Use of an "templated" ordered linked list does imply that the data type used in the template enables ordering (i.e. defines the < operator among others). Be sure to overload the operators necessary for this feature. Your problems will be ordered within the list by priority code and date. For any two problems having the same criticality level (1 being highest), declare the problem having the earliest date as the higher priority.

Your overall object oriented design should allow you to practice abstraction and limit you driver program to the following (assuming your class is called ProblemList):

ProblemList problems("problems.txt");
ProblemList newProblems("newproblems.txt");
ProblemList solvedProblems("resolvedproblems.txt");

            
problems += newProblems;
problems -= solvedProblems;
problems.writeTop(25);
problems.writeBottom(25);

In addition to other features, this solution implies overloading operators <, ==, and != for your Problem class and += and -= for your ProblemList class.

Finally, your output should be a list of problems to solve (the top 25 in the list) and the problems that you'll not likely ever get to (the bottom 25). Therefore, include two member functions of your ProblemList class: writeTop(n) and writeBottom(n). These will list the n Problem objects at the top of the list and the n objects at the bottom, respectively.

Your lists could be a simple sequential listing like the following.

Priority  Submitted     By       Description
   1      4/25/2013  Jane Doe    Hard drive crash
   ... and so on down the list in order ...

File needed: orderLinkedList.h (Hint: There should be no need to change the linked list class for this solution).

USE COMMENTS!!!a

Deliverables

Deliver the following as your final product:

· Cover page with assignment name, student name, and list of attachments

· Printed copy of all final source code files (.cpp and/or .h files) created in your program (you may omit any use of unchanged source code from the course materials)

· Printed output using the provided input files