The goal of this assignment is to:
We will design an ADT in class to implement a Stack. It should have an interface for the following functions:
Create a Java class that implements the ADT.
Write a series of tests to test each method. Test for failures and successes.
Use your new stack class in another Java program to determine if the following expressions are valid. Valid expressions are made up of the following characters: "X()[]' (that is: double-quote, capital X, open paren, close paren, open bracket, close bracket, single quote, and space. Spaces can appear anywhere. If it contains a "'([ then the next non-X character must match, eg "')].
Note that if a quote or double-quote comes in, treat it as an ending, if the last on the stack is a matching quote. Otherwise, treat it as a starting symbol.
Some tests:
XXXX | valid |
X X X X | valid |
X(XX)X | valid |
(XX) | valid |
(XX)[] | valid |
(["''"]) | valid |
([)] | invalid |
"XXXX XXXX" | valid |
"XXXX XXXX | invalid |
"(XXXX) (XXX)" | valid |
"XXXX" X "XXXX" | valid |
"XXX XXX (X) XXX XXX "XXX"" | valid |
Think of some more problems to test your expression validator.