#include "node.h"// virtual Arithmetica(); #include "arithmetica.h" #include #include "globals.h" #include "ProcessString.h" #include "ProcessDerivative.h" #include "VariableMap.h" #include "NodeCreator.h" Algebra::Algebra() { } vector Algebra::CreateNodes() { //Precondition string is entered //Postcondition- The input is put into "packets" in nodes that are all returned in a vector in the same order in which the user inputted them //If invalid input, the computer will treat it as if it is not entered int k=0; myProcessor = new ProcessString(myLine, k, myVariableMap); return( doProcessing()); } Differentiator::Differentiator() :mySpecialPrecedence(DERIVATIVE_PRECEDENCE) { mySpecialChar.push_back("d"); } vector Differentiator::CreateNodes() { //Precondition string is entered //Postcondition- The input is put into "packets" in nodes that are all returned in a vector in the same order in which the user inputted them //If invalid input, the computer will treat it as if it is not entered int k=0; myProcessor = new ProcessDerivative(myLine, k, myVariableMap); return( doProcessing()); } bool Differentiator::isSpecial() { //returns true if there isSpecial way to makeTrees return true; } bool Differentiator::specialEvaluation(const Node* top) { //Checks if specific node needs special evaluation if(top->precedence()!=mySpecialPrecedence) { return false; } else { for(int k=0;kdescription()) { return true; } } return false; } } Node * Differentiator::specialTreeCreation( stack & nodeStack) { //Processes the node specifically for derivative Node * Top=nodeStack.top(); nodeStack.pop();//pops off top Differentiator * diff=new Differentiator(); NodeCreator * normalNode= new NodeCreator(myVariableMap,diff,true); Top->Right(normalNode->makeNodeTree(nodeStack));//recursively calls to set RHS Top->Left(normalNode->makeNodeTree(nodeStack));//recursively calls to set LHS string key=""; if(Top->description()=="d") { return(Top->takeDerivative(key));//returns new tree to stack } return(new Constant(0)); }