forked from aaronbloomfield/pdr
-
Notifications
You must be signed in to change notification settings - Fork 228
/
TreeCalc.h
38 lines (27 loc) · 1.16 KB
/
TreeCalc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Add your header information here
// TreeCalc.h: Tree Calculator class definition
// CS 2150: Lab 5
// You must submit ALL code to make your project build correctly
#ifndef TREECALC_H
#define TREECALC_H
#include <stack>
#include "TreeNode.h"
using namespace std;
class TreeCalc {
public:
TreeCalc(); // Constructor
~TreeCalc(); // Destructor
void cleanTree(TreeNode* tree); // Deletes tree/frees memory
void readInput(); // Gets data from user
void insert(const string& val); // Puts value in tree
// print methods
void printPrefix(TreeNode* tree) const; // Prints data in prefix form
void printInfix(TreeNode* tree) const; // Prints data in infix form
void printPostfix(TreeNode* tree) const; // Prints data in postfix form
void printOutput() const; // Prints in post, in, pre form
int calculate(); // Calls private calculate method
private:
stack<TreeNode*> expressionStack; // Stack to hold the expression
int calculate(TreeNode* tree) const; // Evaluates tree, returns value
};
#endif