Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Exp - a simple integer mathematical expression
- // Eric McCreath 2018
- public abstract class Exp {
- abstract int evaluate(); // calculate the value of the expression
- abstract String show(); // show an expression
- // In your solution you may only modify the static methods parse, parseExp, and parseTerm.
- // You may not modify the signatures of these methods.
- // You may not modify any other classes or methods.
- // You may not add any fields or methods to this abstract class.
- //<exp> ::= <term> | <exp> + <term> | <exp> - <term>
- //<term> ::= ( <exp> ) | <integer literal>
- public static Exp parse(Tokenizer t) throws ParseException {
- // add code in this method for your solution
- return null;
- }
- private static Exp parseExp(Tokenizer t) throws ParseException {
- // add code in this method for your solution
- }
- private static Exp parseTerm(Tokenizer t) throws ParseException {
- // add code in this method for your solution
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement