public function execute($operatorName) { if ($operatorName == "+") { $addobject = new Add(); $addobject->execute($this->values); //$this->add(); } else { if ($operatorName == "-") { $subtractobject = new Subtract(); $subtractobject->execute($this->values); //$this->subtract (); } else { if ($operatorName == "!") { $factorialobject = new Factorial(); $factorialobject->execute($this->values); //$this->factorial (); } else { try { throw new NoSuchOperator('No such operator!'); } catch (NoSuchOperator $e) { echo 'Caught exception: ' . $e->getMessage(); } } } } }
public function __construct($node, $parent) { parent::__construct($node, $parent); self::$possible_attributes = array_merge(parent::$possible_attributes, self::$possible_attributes); self::$required_attributes = array_merge(parent::$required_attributes, self::$required_attributes); self::$possible_children = array_merge(parent::$possible_children, self::$possible_children); self::$required_children = array_merge(parent::$required_children, self::$required_children); }