mirror of https://github.com/Aelita4/ONP.git
				
				
				
			Code cleanup
This commit is contained in:
		
							parent
							
								
									982b44c666
								
							
						
					
					
						commit
						a2ffa8881a
					
				
							
								
								
									
										173
									
								
								main.cpp
								
								
								
								
							
							
						
						
									
										173
									
								
								main.cpp
								
								
								
								
							| 
						 | 
				
			
			@ -130,8 +130,6 @@ bool checkChar(char c, int type)
 | 
			
		|||
 | 
			
		||||
void heapPointer(int y)
 | 
			
		||||
{
 | 
			
		||||
    /*gotoxy(0, 0);
 | 
			
		||||
    std::cout << y;*/
 | 
			
		||||
    char t = '\0';
 | 
			
		||||
    
 | 
			
		||||
    if(y > 0)
 | 
			
		||||
| 
						 | 
				
			
			@ -195,8 +193,6 @@ void displayNumBuilder(int n)
 | 
			
		|||
        i /= 10;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //std::cout << 10 - len;
 | 
			
		||||
 | 
			
		||||
    gotoxy(2, 2);
 | 
			
		||||
    color(RED, BLACK);
 | 
			
		||||
    std::cout << n;
 | 
			
		||||
| 
						 | 
				
			
			@ -238,9 +234,6 @@ std::string stringToONP(std::string s, int speed = 500)
 | 
			
		|||
			for (; counter > 0; counter--)
 | 
			
		||||
			{
 | 
			
		||||
				out += heap[counter - 1];
 | 
			
		||||
				/*gotoxy(3 + (2 * (counter - 1)), 2);
 | 
			
		||||
				color(RED, BLACK);
 | 
			
		||||
				std::cout << " ";*/
 | 
			
		||||
                gotoxy(2, 3 + counter);
 | 
			
		||||
                color(YELLOW, LIGHT_PURPLE);
 | 
			
		||||
                std::cout << " ";
 | 
			
		||||
| 
						 | 
				
			
			@ -269,7 +262,6 @@ std::string stringToONP(std::string s, int speed = 500)
 | 
			
		|||
            numBuild += (numBuildCount * (tmp - '0'));
 | 
			
		||||
            numBuildCount *= 10;
 | 
			
		||||
            displayNumBuilder(numBuild);
 | 
			
		||||
			//out += tmp;
 | 
			
		||||
			break;
 | 
			
		||||
		case '+':
 | 
			
		||||
		case '-':
 | 
			
		||||
| 
						 | 
				
			
			@ -291,20 +283,12 @@ std::string stringToONP(std::string s, int speed = 500)
 | 
			
		|||
				out += heap[--counter];
 | 
			
		||||
                heapPointer(counter);
 | 
			
		||||
				heap[counter] = '\0';
 | 
			
		||||
				/*gotoxy(3 + (2 * counter), 2);
 | 
			
		||||
				color(RED, BLACK);
 | 
			
		||||
				std::cout << " ";
 | 
			
		||||
				color(WHITE, BLACK);*/
 | 
			
		||||
                gotoxy(2, 3 + counter);
 | 
			
		||||
                color(YELLOW, LIGHT_PURPLE);
 | 
			
		||||
                if(counter != 0) std::cout << " ";
 | 
			
		||||
                color(WHITE, BLACK);
 | 
			
		||||
			}
 | 
			
		||||
			heap[counter] = tmp;
 | 
			
		||||
			/*gotoxy(3 + (2 * counter), 2);
 | 
			
		||||
			color(RED, BLACK);
 | 
			
		||||
			std::cout << tmp;
 | 
			
		||||
			color(WHITE, BLACK);*/
 | 
			
		||||
            heapPointer(counter + 1);
 | 
			
		||||
            gotoxy(2, 4 + counter);
 | 
			
		||||
            color(YELLOW, LIGHT_PURPLE);
 | 
			
		||||
| 
						 | 
				
			
			@ -314,10 +298,6 @@ std::string stringToONP(std::string s, int speed = 500)
 | 
			
		|||
			break;
 | 
			
		||||
		case '(':
 | 
			
		||||
			heap[counter] = tmp;
 | 
			
		||||
			/*gotoxy(3 + (2 * counter), 2);
 | 
			
		||||
			color(RED, BLACK);
 | 
			
		||||
			std::cout << tmp;
 | 
			
		||||
			color(WHITE, BLACK);*/
 | 
			
		||||
            heapPointer(counter + 1);
 | 
			
		||||
            gotoxy(2, 4 + counter);
 | 
			
		||||
            color(YELLOW, LIGHT_PURPLE);
 | 
			
		||||
| 
						 | 
				
			
			@ -340,20 +320,12 @@ std::string stringToONP(std::string s, int speed = 500)
 | 
			
		|||
				out += heap[--counter];
 | 
			
		||||
                heapPointer(counter);
 | 
			
		||||
				heap[counter] = '\0';
 | 
			
		||||
				/*gotoxy(3 + (2 * counter), 2);
 | 
			
		||||
				color(RED, BLACK);
 | 
			
		||||
				std::cout << " ";
 | 
			
		||||
				color(WHITE, BLACK);*/
 | 
			
		||||
                gotoxy(2, 3 + counter);
 | 
			
		||||
                color(YELLOW, LIGHT_PURPLE);
 | 
			
		||||
                if(counter != 0) std::cout << " ";
 | 
			
		||||
                color(WHITE, BLACK);
 | 
			
		||||
			}
 | 
			
		||||
			heap[counter] = tmp;
 | 
			
		||||
			/*gotoxy(3 + (2 * counter), 2);
 | 
			
		||||
			color(RED, BLACK);
 | 
			
		||||
			std::cout << tmp;
 | 
			
		||||
			color(WHITE, BLACK);*/
 | 
			
		||||
            heapPointer(counter + 1);
 | 
			
		||||
            gotoxy(2, 4 + counter);
 | 
			
		||||
            color(YELLOW, LIGHT_PURPLE);
 | 
			
		||||
| 
						 | 
				
			
			@ -367,7 +339,6 @@ std::string stringToONP(std::string s, int speed = 500)
 | 
			
		|||
				{
 | 
			
		||||
					out += heap[counter];
 | 
			
		||||
					heap[counter] = '\0';
 | 
			
		||||
					//gotoxy(3 + (2 * counter), 2);
 | 
			
		||||
                    gotoxy(2, 4 + counter);
 | 
			
		||||
                    color(YELLOW, LIGHT_PURPLE);
 | 
			
		||||
					std::cout << " ";
 | 
			
		||||
| 
						 | 
				
			
			@ -376,10 +347,6 @@ std::string stringToONP(std::string s, int speed = 500)
 | 
			
		|||
			}
 | 
			
		||||
 | 
			
		||||
			heap[counter] = '\0';
 | 
			
		||||
			/*gotoxy(3 + (2 * counter), 2);
 | 
			
		||||
			color(RED, BLACK);
 | 
			
		||||
			std::cout << " ";
 | 
			
		||||
			color(WHITE, BLACK);*/
 | 
			
		||||
            heapPointer(counter + 1);
 | 
			
		||||
            gotoxy(2, 4 + counter);
 | 
			
		||||
            color(YELLOW, LIGHT_PURPLE);
 | 
			
		||||
| 
						 | 
				
			
			@ -415,7 +382,6 @@ int calculateONP(std::string s, int speed = 500)
 | 
			
		|||
 | 
			
		||||
	for (int i = 0; i < len; i++)
 | 
			
		||||
	{
 | 
			
		||||
		//gotoxy(1 + i, 8);
 | 
			
		||||
        color(LIGHT_GREEN, BLACK);
 | 
			
		||||
		gotoxy(41 + i, 4);
 | 
			
		||||
        std::cout << " ^";
 | 
			
		||||
| 
						 | 
				
			
			@ -424,11 +390,8 @@ int calculateONP(std::string s, int speed = 500)
 | 
			
		|||
		{
 | 
			
		||||
        case ';':
 | 
			
		||||
            heap[counter] = numBuild;
 | 
			
		||||
			//gotoxy(3 + (2 * counter), 2);
 | 
			
		||||
 | 
			
		||||
            gotoxy(42 + i, 3);
 | 
			
		||||
            color(LIGHT_GREEN, BLACK);
 | 
			
		||||
            //std::cout << numBuild;
 | 
			
		||||
            gotoxy(41 + i, 4);
 | 
			
		||||
            std::cout << " ^";
 | 
			
		||||
			color(WHITE, BLACK);
 | 
			
		||||
| 
						 | 
				
			
			@ -468,30 +431,14 @@ int calculateONP(std::string s, int speed = 500)
 | 
			
		|||
            gotoxy(41 + i, 4);
 | 
			
		||||
            std::cout << " ^";
 | 
			
		||||
			color(WHITE, BLACK);
 | 
			
		||||
			/*heap[counter] = tmp - '0';
 | 
			
		||||
			//gotoxy(3 + (2 * counter), 2);
 | 
			
		||||
            gotoxy(2, 4 + counter);
 | 
			
		||||
            color(YELLOW, LIGHT_PURPLE);
 | 
			
		||||
			std::cout << tmp;
 | 
			
		||||
            gotoxy(42 + i, 3);
 | 
			
		||||
            color(LIGHT_GREEN, BLACK);
 | 
			
		||||
            std::cout << tmp;
 | 
			
		||||
            gotoxy(41 + i, 4);
 | 
			
		||||
            std::cout << " ^";
 | 
			
		||||
			color(WHITE, BLACK);
 | 
			
		||||
			counter++;
 | 
			
		||||
            heapPointer(counter);*/
 | 
			
		||||
			break;
 | 
			
		||||
		case '+':
 | 
			
		||||
			calculate = heap[counter - 2] + heap[counter - 1];
 | 
			
		||||
			heap[counter - 2] = 0;
 | 
			
		||||
			heap[counter - 1] = 0;
 | 
			
		||||
            //(((2+2)+2)+2)+2=
 | 
			
		||||
			//gotoxy(3 + (2 * (counter - 2)), 2);
 | 
			
		||||
			gotoxy(2, 4 + counter - 2);
 | 
			
		||||
            color(YELLOW, BLACK);
 | 
			
		||||
			std::cout << "  ";
 | 
			
		||||
			//gotoxy(3 + (2 * (counter - 1)), 2);
 | 
			
		||||
			gotoxy(2, 4 + counter - 1);
 | 
			
		||||
            std::cout << "  ";
 | 
			
		||||
			counter -= 2;
 | 
			
		||||
| 
						 | 
				
			
			@ -499,7 +446,6 @@ int calculateONP(std::string s, int speed = 500)
 | 
			
		|||
			heap[counter++] = calculate;
 | 
			
		||||
            heapPointer(counter);
 | 
			
		||||
            color(YELLOW, BLACK);
 | 
			
		||||
			//gotoxy(3 + (2 * (counter - 1)), 2);
 | 
			
		||||
			gotoxy(2, 4 + counter - 1);
 | 
			
		||||
            std::cout << calculate;
 | 
			
		||||
            gotoxy(42 + i, 3);
 | 
			
		||||
| 
						 | 
				
			
			@ -510,39 +456,12 @@ int calculateONP(std::string s, int speed = 500)
 | 
			
		|||
			color(WHITE, BLACK);
 | 
			
		||||
			break;
 | 
			
		||||
		case '-':
 | 
			
		||||
			/*calculate = heap[counter - 2] - heap[counter - 1];
 | 
			
		||||
			heap[counter - 2] = 0;
 | 
			
		||||
			heap[counter - 1] = 0;
 | 
			
		||||
			//gotoxy(3 + (2 * (counter - 2)), 2);
 | 
			
		||||
            gotoxy(2, 4 + counter - 2);
 | 
			
		||||
            color(YELLOW, LIGHT_PURPLE);
 | 
			
		||||
			std::cout << "  ";
 | 
			
		||||
			//gotoxy(3 + (2 * (counter - 1)), 2);
 | 
			
		||||
            gotoxy(2, 4 + counter - 1);
 | 
			
		||||
			std::cout << "  ";
 | 
			
		||||
			counter -= 2;
 | 
			
		||||
            heapPointer(counter);
 | 
			
		||||
			heap[counter++] = calculate;
 | 
			
		||||
            heapPointer(counter);
 | 
			
		||||
            color(YELLOW, LIGHT_PURPLE);
 | 
			
		||||
			//gotoxy(3 + (2 * (counter - 1)), 2);
 | 
			
		||||
            gotoxy(2, 4 + counter - 1);
 | 
			
		||||
			std::cout << calculate;
 | 
			
		||||
            gotoxy(42 + i, 3);
 | 
			
		||||
            color(LIGHT_GREEN, BLACK);
 | 
			
		||||
            std::cout << tmp;
 | 
			
		||||
            gotoxy(41 + i, 4);
 | 
			
		||||
            std::cout << " ^";
 | 
			
		||||
			color(WHITE, BLACK);*/
 | 
			
		||||
            calculate = heap[counter - 2] - heap[counter - 1];
 | 
			
		||||
			heap[counter - 2] = 0;
 | 
			
		||||
			heap[counter - 1] = 0;
 | 
			
		||||
            //(((2+2)+2)+2)+2=
 | 
			
		||||
			//gotoxy(3 + (2 * (counter - 2)), 2);
 | 
			
		||||
			gotoxy(2, 4 + counter - 2);
 | 
			
		||||
            color(YELLOW, BLACK);
 | 
			
		||||
			std::cout << "  ";
 | 
			
		||||
			//gotoxy(3 + (2 * (counter - 1)), 2);
 | 
			
		||||
			gotoxy(2, 4 + counter - 1);
 | 
			
		||||
            std::cout << "  ";
 | 
			
		||||
			counter -= 2;
 | 
			
		||||
| 
						 | 
				
			
			@ -550,7 +469,6 @@ int calculateONP(std::string s, int speed = 500)
 | 
			
		|||
			heap[counter++] = calculate;
 | 
			
		||||
            heapPointer(counter);
 | 
			
		||||
            color(YELLOW, BLACK);
 | 
			
		||||
			//gotoxy(3 + (2 * (counter - 1)), 2);
 | 
			
		||||
			gotoxy(2, 4 + counter - 1);
 | 
			
		||||
            std::cout << calculate;
 | 
			
		||||
            gotoxy(42 + i, 3);
 | 
			
		||||
| 
						 | 
				
			
			@ -561,39 +479,12 @@ int calculateONP(std::string s, int speed = 500)
 | 
			
		|||
			color(WHITE, BLACK);
 | 
			
		||||
			break;
 | 
			
		||||
		case '*':
 | 
			
		||||
			/*calculate = heap[counter - 2] * heap[counter - 1];
 | 
			
		||||
			heap[counter - 2] = 0;
 | 
			
		||||
			heap[counter - 1] = 0;
 | 
			
		||||
			//gotoxy(3 + (2 * (counter - 2)), 2);
 | 
			
		||||
            gotoxy(2, 4 + counter - 2);
 | 
			
		||||
            color(YELLOW, LIGHT_PURPLE);
 | 
			
		||||
			std::cout << "  ";
 | 
			
		||||
			//gotoxy(3 + (2 * (counter - 1)), 2);
 | 
			
		||||
            gotoxy(2, 4 + counter - 1);
 | 
			
		||||
			std::cout << "  ";
 | 
			
		||||
			counter -= 2;
 | 
			
		||||
            heapPointer(counter);
 | 
			
		||||
			heap[counter++] = calculate;
 | 
			
		||||
            heapPointer(counter);
 | 
			
		||||
            color(YELLOW, LIGHT_PURPLE);
 | 
			
		||||
			//gotoxy(3 + (2 * (counter - 1)), 2);
 | 
			
		||||
            gotoxy(2, 4 + counter - 1);
 | 
			
		||||
			std::cout << calculate;
 | 
			
		||||
            gotoxy(42 + i, 3);
 | 
			
		||||
            color(LIGHT_GREEN, BLACK);
 | 
			
		||||
            std::cout << tmp;
 | 
			
		||||
            gotoxy(41 + i, 4);
 | 
			
		||||
            std::cout << " ^";
 | 
			
		||||
			color(WHITE, BLACK);*/
 | 
			
		||||
            calculate = heap[counter - 2] * heap[counter - 1];
 | 
			
		||||
			heap[counter - 2] = 0;
 | 
			
		||||
			heap[counter - 1] = 0;
 | 
			
		||||
            //(((2+2)+2)+2)+2=
 | 
			
		||||
			//gotoxy(3 + (2 * (counter - 2)), 2);
 | 
			
		||||
			gotoxy(2, 4 + counter - 2);
 | 
			
		||||
            color(YELLOW, BLACK);
 | 
			
		||||
			std::cout << "  ";
 | 
			
		||||
			//gotoxy(3 + (2 * (counter - 1)), 2);
 | 
			
		||||
			gotoxy(2, 4 + counter - 1);
 | 
			
		||||
            std::cout << "  ";
 | 
			
		||||
			counter -= 2;
 | 
			
		||||
| 
						 | 
				
			
			@ -601,7 +492,6 @@ int calculateONP(std::string s, int speed = 500)
 | 
			
		|||
			heap[counter++] = calculate;
 | 
			
		||||
            heapPointer(counter);
 | 
			
		||||
            color(YELLOW, BLACK);
 | 
			
		||||
			//gotoxy(3 + (2 * (counter - 1)), 2);
 | 
			
		||||
			gotoxy(2, 4 + counter - 1);
 | 
			
		||||
            std::cout << calculate;
 | 
			
		||||
            gotoxy(42 + i, 3);
 | 
			
		||||
| 
						 | 
				
			
			@ -629,44 +519,15 @@ int calculateONP(std::string s, int speed = 500)
 | 
			
		|||
                std::cout << i + 1;
 | 
			
		||||
                color(RED, BLACK);
 | 
			
		||||
                std::cout << " (division by zero)";   
 | 
			
		||||
				/*gotoxy(2, 11);
 | 
			
		||||
				std::cout << "DIV_ZERO_ERROR";*/
 | 
			
		||||
				color(WHITE, BLACK);
 | 
			
		||||
				return 0;
 | 
			
		||||
			}
 | 
			
		||||
			/*calculate = heap[counter - 2] / heap[counter - 1];
 | 
			
		||||
			heap[counter - 2] = 0;
 | 
			
		||||
			heap[counter - 1] = 0;
 | 
			
		||||
			//gotoxy(3 + (2 * (counter - 2)), 2);
 | 
			
		||||
            gotoxy(2, 4 + counter - 2);
 | 
			
		||||
            color(YELLOW, LIGHT_PURPLE);
 | 
			
		||||
			std::cout << "  ";
 | 
			
		||||
			//gotoxy(3 + (2 * (counter - 1)), 2);
 | 
			
		||||
            gotoxy(2, 4 + counter - 1);
 | 
			
		||||
			std::cout << "  ";
 | 
			
		||||
			counter -= 2;
 | 
			
		||||
            heapPointer(counter);
 | 
			
		||||
			heap[counter++] = calculate;
 | 
			
		||||
            heapPointer(counter);
 | 
			
		||||
            color(YELLOW, LIGHT_PURPLE);
 | 
			
		||||
			//gotoxy(3 + (2 * (counter - 1)), 2);
 | 
			
		||||
            gotoxy(2, 4 + counter - 1);
 | 
			
		||||
			std::cout << calculate;
 | 
			
		||||
            gotoxy(42 + i, 3);
 | 
			
		||||
            color(LIGHT_GREEN, BLACK);
 | 
			
		||||
            std::cout << tmp;
 | 
			
		||||
            gotoxy(41 + i, 4);
 | 
			
		||||
            std::cout << " ^";
 | 
			
		||||
			color(WHITE, BLACK);*/
 | 
			
		||||
            calculate = heap[counter - 2] / heap[counter - 1];
 | 
			
		||||
			heap[counter - 2] = 0;
 | 
			
		||||
			heap[counter - 1] = 0;
 | 
			
		||||
            //(((2+2)+2)+2)+2=
 | 
			
		||||
			//gotoxy(3 + (2 * (counter - 2)), 2);
 | 
			
		||||
			gotoxy(2, 4 + counter - 2);
 | 
			
		||||
            color(YELLOW, BLACK);
 | 
			
		||||
			std::cout << "  ";
 | 
			
		||||
			//gotoxy(3 + (2 * (counter - 1)), 2);
 | 
			
		||||
			gotoxy(2, 4 + counter - 1);
 | 
			
		||||
            std::cout << "  ";
 | 
			
		||||
			counter -= 2;
 | 
			
		||||
| 
						 | 
				
			
			@ -674,7 +535,6 @@ int calculateONP(std::string s, int speed = 500)
 | 
			
		|||
			heap[counter++] = calculate;
 | 
			
		||||
            heapPointer(counter);
 | 
			
		||||
            color(YELLOW, BLACK);
 | 
			
		||||
			//gotoxy(3 + (2 * (counter - 1)), 2);
 | 
			
		||||
			gotoxy(2, 4 + counter - 1);
 | 
			
		||||
            std::cout << calculate;
 | 
			
		||||
            gotoxy(42 + i, 3);
 | 
			
		||||
| 
						 | 
				
			
			@ -867,32 +727,25 @@ bool validate(std::string s, int speed = 250)
 | 
			
		|||
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
/**
 | 
			
		||||
 * @param argv[1] equation
 | 
			
		||||
 * @param argv[2] check speed in ms
 | 
			
		||||
 * @param argv[3] convert speed in ms
 | 
			
		||||
 * @param argv[4] calculation speed in ms
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
int main(int argc, char *argv[])
 | 
			
		||||
{
 | 
			
		||||
    /*std::cout << argc << std::endl;
 | 
			
		||||
    for(int i = 0; i < argc; i++) std::cout << argv[i] << std::endl;
 | 
			
		||||
    system("pause");
 | 
			
		||||
    return 0;*/
 | 
			
		||||
	//std::string equation = "((7+3)/5*4*(4-2))/2=";
 | 
			
		||||
    //std::string equation = "4;/0=";
 | 
			
		||||
 | 
			
		||||
    std::stringstream tmp1, tmp2, tmp3;
 | 
			
		||||
    int sp1, sp2, sp3;
 | 
			
		||||
    tmp1 << argv[2];
 | 
			
		||||
    tmp2 << argv[3];
 | 
			
		||||
    tmp3 << argv[4];
 | 
			
		||||
    tmp1 >> sp1;
 | 
			
		||||
    tmp2 >> sp2;
 | 
			
		||||
    tmp3 >> sp3;
 | 
			
		||||
    if(argc >= 4) {
 | 
			
		||||
        tmp1 << argv[2];
 | 
			
		||||
        tmp2 << argv[3];
 | 
			
		||||
        tmp3 << argv[4];
 | 
			
		||||
        tmp1 >> sp1;
 | 
			
		||||
        tmp2 >> sp2;
 | 
			
		||||
        tmp3 >> sp3;
 | 
			
		||||
    } else {
 | 
			
		||||
        sp1 = 100;
 | 
			
		||||
        sp2 = 100;
 | 
			
		||||
        sp3 = 100;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
	system("cls");
 | 
			
		||||
    //system("pause > NUL");
 | 
			
		||||
 | 
			
		||||
    color(GREEN, GREEN);
 | 
			
		||||
    for(int i = 1; i <= 28; i++)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue