forked from aaronbloomfield/pdr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTreeCalc.h
More file actions
39 lines (28 loc) · 1.15 KB
/
Copy pathTreeCalc.h
File metadata and controls
39 lines (28 loc) · 1.15 KB
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
39
// Add your header information here
// TreeCalc.h: Tree Calculator class definition
// CS 2150: Lab 5
// NOTE: You may use any stack implementation that you wish
// You must submit ALL code to make your project build correctly
#ifndef TREECALC_H
#define TREECALC_H
// include your stack implementation here
#include "TreeNode.h"
using namespace std;
class TreeCalc {
public:
TreeCalc(); //Constructor
~TreeCalc(); //Destructor
void cleanTree(TreeNode * ptr); //Deletes tree/frees memory
void readInput(); //gets data from user
void insert(const string & val); //puts value in tree
// print methods
void printPrefix(TreeNode * curNode) const; //prints data in prefix form
void printInfix(TreeNode * curNode) const; //prints data in infix form
void printPostfix(TreeNode * curNode) const;//prints data in postfix form
void printOutput() const; //prints in pre,in,post form
int calculate(); //calls private calculate method
private:
// declare a stack to hold your expression tree
int calculate(TreeNode* ptr) const; //Evaluates tree, returns value
};
#endif