#include #include #include #include #include "node.h" #include "Calculator.h" #include "NodeCreator.h" #include "VariableMap.h" #include "globals.h" #include "arithmetica.h" using namespace std; /** *The Calulator class is responsible for assigning tasks to other functions. *It does all of its work from the function performCalculations. *These functions are found in the NodeCreator class, which parses the *input and forms with a evaluatable node. The Calculator class then calls *on the evaluation() function of Node in order to process the node and *produce a final numerical answer. The value of the node is stored, and *so is the description of the node. * *Written by Jessica Smith */ //constructor Calculator::Calculator(Arithmetica * processortype) :myProcessorType(processortype) { } void Calculator::performCalculations() { //repeated until user chooses to stop this funtion calls all of the function to process and calculate VariableMap VarMap; //one map is created to store all //variables for current run. int count=1; string line; cout<"; while(getline(cin,line))//gets the user's input { count ++; if(line[0]!=COMMENT_CHARACTER) { myProcessorType->GetVariableMap(VarMap); myProcessorType->GetInput(line); NodeCreator * listNodes =new NodeCreator(VarMap,myProcessorType,myProcessorType->isSpecial()); vector NodeList; //stores all nodes created stack StackList; NodeList =myProcessorType->CreateNodes();//creates the nodes from input StackList=listNodes->makePostfix(NodeList);//creates postfix version Node* mainNode =listNodes->makeNodeTree(StackList);//creates the single node if(mainNode->evaluate()==0&&mainNode->getAlert()) { cout<description())->evaluate()<description(),mainNode); } } else{ cout<";; } }