#include #include using namespace std; #include "expression.h" #include "parser.h" #include "int_parser.h" #include "img_parser.h" #include "bool_parser.h" void arithmetica() { string line; IntParser myParser; int linecount(1); cout << "Welcome to Arithmetica" << endl; while(1) { printf("%d-> ",linecount++); getline(cin,line); if(line == ".") break; if(line == "help") myParser.Help(); else{ Expression * expr = myParser.Process(line); //cout << "Got this far. " << endl; if(expr != 0){ cout << expr->evaluate() << endl; cout << expr->toString() << endl; } } } return; } void imagemetica () { string line; ImgParser myParser; int linecount(1); cout << "Welcome to Imagemetica" << endl; while(printf("%d-> ",linecount++) && getline(cin,line) && line != ".") { if(line == "help") myParser.Help(); Expression * expr = myParser.Process(line); if(expr != 0) myParser.display(expr->evaluate()); } return; } void boolmetica () { string line; BoolParser myParser; int linecount(1); cout << "Welcome to BoolMetica" << endl; while(printf("%d-> ",linecount++) && getline(cin,line) && line != ".") { if(line == "help") myParser.Help(); Expression * expr = myParser.Process(line); if(expr != 0) cout << expr->evaluate() << endl; } return; } int main () { cout << "Welcome to OOLALA\n"; while(1) { cout << "What would you like to play?\n"; cout << "1) Arithmetica\n2) BoolMetica\n3) Imagemetica\n"; cout << ". quit (1,2,3, .)\n"; string choice; getline(cin,choice); switch(choice[0]) { case('1'): arithmetica(); break; case('2'): boolmetica(); break; case('3'): imagemetica(); break; case('.'): return 0; default: cout << "Please enter a valid choice." << endl << endl; } } return 0; }