Lab 9
Due 9:40AM November 19, 2008
- Implement a Stack class that stores data using the doubly
linked list you implemented for question 1. Your stack will
support the following operations:
public void push(Object o)
-
insert object o on the top of the stack
public Object pop() throws
StackEmptyException
- return the top element on the stack.
If the stack is empty, throw a StackEmptyException.
public Object top() throws
StackEmptyException
- return the top element on the stack without removing it.
If the stack is empty, throw a StackEmptyException.
public int size()
- return the
size of the stack
- 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
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. You queue
must support the operations
enqueue
, dequeue
,
size
, and front
.
Sami
Rollins