Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;public class SyntaxChecker {private String expression; // expression to validate private Stack<String> stack; // holds opening symbols ONLYprivate String open; // opening symbolsprivate String close; // closing symbols // TODO: initialize the instance variables expression, stack, open, close public SyntaxChecker(String open, String close, String exp) {}// TODO complete the checkExpressions method that determines if the expression// has a closing symbol for every opening symbol // @return true if the expression is valid, false otherwisepublic boolean checkExpression() { return false;} // This method calls the checkExpression method and will determine if the // expression is valid (every opening symbol, has a closing symbol) // A string is return with a validation message // @return a validation message public String validate() { String result=""; if (checkExpression()==true)result += expression + " is correct\n";elseresult += expression + " is incorrect\n";return result; }public String toString() {return "Expression: " + expression + "\nStack: " + stack + "\nOpen: " +open + "Close: " + close;}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement