This commit is contained in:
2025-05-19 14:13:55 -05:00
parent cb5762a3fe
commit f6ad110880

View File

@@ -114,6 +114,8 @@ double Calculator::evaluate(std::string equation, std::unordered_map<char, std::
return std::stod(equation);
}
break;
default:
break;
}
}
//op is now the appropriate operator
@@ -146,6 +148,8 @@ double Calculator::evaluate(std::string equation, std::unordered_map<char, std::
return a + b;
case '-':
return a - b;
default:
break;
}
}
@@ -155,6 +159,12 @@ std::string Calculator::calculate(std::string equation) {
while(equation.find(' ') != std::string::npos) {
equation.erase(equation.find(' '), 1);
}
while(equation.find('\t') != std::string::npos) {
equation.erase(equation.find('\t'), 1);
}
while(equation.find('\n') != std::string::npos) {
equation.erase(equation.find('\n'), 1);
}
std::unordered_map<unsigned int, std::string> nodes;
std::unordered_map<char, std::string> evalStr;
@@ -257,19 +267,16 @@ void Calculator::basicCalculator() {
s.clear();
}
ImGui::SameLine();
if(ImGui::Button("()")) {
if(parenthesis) {
s += " ( ";
} else {
s += " ) ";
}
parenthesis = !parenthesis;
if(ImGui::Button("(")) {
s += " ( ";
}
ImGui::SameLine();
if(ImGui::Button("Gr")) {
graphing = true;
if(ImGui::Button(")")) {
s += " ) ";
}
ImGui::SameLine();
if(ImGui::Button("^")) {
s += " ^ ";
}
ImGui::SameLine();
if(ImGui::Button("=")) {