For your eighth lab, you will use the Stack data structure that you
wrote in your previous lab.
- Implement a text editor. Your editor will display a string of
characters and a cursor. Your program will allow the user to move the
cursor and modify the text using the following five operations:
- right - move the cursor to the right one character or do
nothing if at the end of the line
- left - move the cursor to the left one character or do
nothing if at the end of the line
- rdelete n - delete n characters to the right of the cursor
- ldelete n - delete n characters to the left of the cursor
- insert c - insert the character c just before the cursor
- quit - stop editing
Your editor should repeatedly print the current line of text, and then
promt the user to type in one of the commands from the keyboard.
Use 2 stacks to store the characters - one to store the chars to the
left of the cursor and one to store the chars to the right of the
cursor.
- Implement a queue using two stacks. Your queue should have
enqueue, dequeue, and empty methods, and should store all of the data
for the queue in two stacks. You should use no other data
structures than the two stacks, and should only call the push, pop, and
empty methods of the stack to implement the queue. You should
also write a main program that tests your queue.,
Grading
- Text Editor: (65 points total)
- Program decomposition / following coding conventions / style 10
points
(you should probably have an Editor class, for instance, which your
main program calls ...)
- Handling user input / main program 10 points
- left/right 10 points
- rdelete 10 points
- ldelete 10 points
- insert 10 points
- quit 5 points
- Queue From Stacks: (35 points total)
- Enqueue 15 points
- Dequeue 15 points
- Main program (to test your queue) 5 points.
Submission
All file(s) required for
your project should be in the folder
https://www.cs.usfca.edu/svn/<username>/cs112/Lab9/