// We append three files here. You should separate them and use them. // You should implement the majority of these methods // plus others if you find necessary. // The code represents the correct structure and we should use it // you may need to check the correctness though. // If you think you should implement it in a different way // you should write it in your report and explain why. // Michalis // ----------- global.h -------------- #include #include #include #include #include #define NOOP 0 #define MIN -1 #define MAX -2 #define AVG -3 #define min(a, b) (((a) < (b)) ? (a) : (b)) #define max(a, b) (((a) > (b)) ? (a) : (b)) // ------------------ node.h ---------------------------------- #include "global.h" class node { private: double val; int oper; node* left; node* right; public: node(); // be careful in initializing ~node(); bool isNum(); // is the node simple number? void readtree(); double evaluate(); void SetValue(double v); // change val double GetValue(); void SetOper(int o); int GetOper(); void SetLeft(node* l); node* GetLeft(); void SetRight(node* r); node* GetRight(); }; // --------------------- token.h ------------------ #include "global.h" // token is a single element you read form the file // either an operator or a number class token { private: double val; int oper; public: token() ; ~token(); bool isNum(); // is it a number? void SetValue(double v); double GetValue(); void SetOper(int o); int GetOper(); }