Question: Goal The purpose of the second programming assignment is to experience stacks, queues, and new data structures. The data structure for this assignment is a
Goal
The purpose of the second programming assignment is to experience stacks, queues, and new data structures. The data structure for this assignment is a doubly linked list.
Problem Statement
Have you wondered how the editors do undo and redo actions? In this assignment you are going to design and implement a data structure that helps solving the undo and redo problem. In order to be able to undo or redo some editing commands, you need to keep track of the command history. We are going to use a deque for that. Deque is sometimes called doubleended queue. You can add and remove from both ends.
Programming
Part I: The Deque ADT
The deque will represent the command history for our assignment.
The command should include:
sequence number of the command, eg and they should not change throughout the program
command description, eg copy line
The deque should be implemented using a doubly linked list of commands, where the front pointer points to the command that will be used for redo and the rear pointer points to the most recent command. You must implement
addToEnd
removeFromEnd
addToFront
removeFromFront
peekEnd
peekFront
display
Part II: The Driver or the Test Program
The test program needs to first load the test data set from external file at the beginning of the program. The menubased user interface should allow user to do the following:
Show the entire command history
Undo a certain number of commands
Redo a certain number of commands the opposite of undo
Here is an example of undoing and redoing and it should give you hint about how to implement the undoredo operations:
After loading from file, the command history:
copy line
paste line after line
remove line
remove the first words of line
join line and
replace all occurrences of "num" to "number"
comment out line
indent line
unindent line
uncomment line
After undo commands, the command history:
indent line
unindent line
uncomment line
copy line
paste line after line
remove line
remove the first words of line
join line and
replace all occurrences of "num" to "number"
comment out line
After redo commands, the command history:
uncomment line
copy line
paste line after line
remove line
remove the first words of line
join line and
replace all occurrences of "num" to "number"
comment out line
indent line
unindent line
Things you should know...as part of your program
Do not use statically allocated arrays in your classes or structures used by the ADT.
All data members in a class must be private
Never perform input operations from your data structure class in CS
Global variables are not allowed in CS
Do not use the String class! use arrays of characters instead! You may use the cstring library.
Use modular design, separating the h files from the cpp files. Remember, h files should contain the class header and any necessary prototypes. The cpp files should contain function definitions. Never #include" cpp files!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
