/** * Copyright (c): Uwe Schmidt, FH Wedel * * You may study, modify and distribute this source code * FOR NON-COMMERCIAL PURPOSES ONLY. * This copyright message has to remain unchanged. * * Note that this document is provided 'as is', * WITHOUT WARRANTY of any kind either expressed or implied. */ abstract class UnaryExpr extends Expr { // der Operanden-Ausdruck protected Expr operand; //-------------------- protected UnaryExpr(Expr operand) { this.operand = operand; } public Object eval() { Object v1 = operand.eval(); return op1(v1); } public String toString() { return "(" + op1ToString() + operand.toString() + ")"; } // Schablonenmethoden fuer einstellige Operationen protected abstract Object op1(Object v1); protected abstract String op1ToString(); }