Build an Expression Evaluator
Visitor pattern
Challenge 3 of Actions as ObjectsAdvanced~55 minFree
Build an arithmetic expression tree and learn the Visitor pattern by adding operations to it. You will give nodes an accept method for double dispatch, write an evaluator, add a new node type, then add printing and node-counting visitors — each a new operation with zero changes to the node classes.