Initial commit
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
#include <iostream>
|
||||
#include "basecalc.h"
|
||||
#include <memory>
|
||||
#include "input_resolver.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
auto calc = std::make_unique<BaseCalculator>();
|
||||
|
||||
std::cout << "Initializing calculator";
|
||||
|
||||
while (true)
|
||||
{
|
||||
std::cout << "What's your next input? (+,-,*,/,%,$,q,p)";
|
||||
auto command = resolveCommand();
|
||||
|
||||
if (command.shouldTerminate())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
switch(command.getNextChar())
|
||||
{
|
||||
case '+':
|
||||
{
|
||||
calc->calculate({OpType::Addition, static_cast<int>(*calc), command.getNextArg()});
|
||||
}
|
||||
break;
|
||||
|
||||
case '-':
|
||||
{
|
||||
calc->calculate({OpType::Subtraction, static_cast<int>(*calc), command.getNextArg()});
|
||||
}
|
||||
break;
|
||||
|
||||
case '*':
|
||||
{
|
||||
calc->calculate({OpType::Multiplication, static_cast<int>(*calc), command.getNextArg()});
|
||||
}
|
||||
break;
|
||||
|
||||
case '/':
|
||||
{
|
||||
calc->calculate({OpType::Division, static_cast<int>(*calc), command.getNextArg()});
|
||||
}
|
||||
break;
|
||||
|
||||
case '%':
|
||||
{
|
||||
calc->calculate({OpType::Modulo, static_cast<int>(*calc), command.getNextArg()});
|
||||
}
|
||||
break;
|
||||
|
||||
case '$':
|
||||
{
|
||||
calc->calculate({OpType::Special, static_cast<int>(*calc)});
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if(command.shouldPrint())
|
||||
std::cout << "Intermediary result: " << static_cast<int>(*calc) << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "Final output: " << static_cast<int>(*calc) << std::endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user