-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathExpressionManager.h
64 lines (56 loc) · 2.11 KB
/
ExpressionManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#pragma once
#include <iostream>
#include <string>
#include <stack>
#include "ExpressionManagerInterface.h"
using namespace std;
class ExpressionManager: public ExpressionManagerInterface
{
public:
ExpressionManager() {}
virtual ~ExpressionManager() {}
/*
* Checks whether an expression has balanced parentheses
*
* - The given expression will have a space between every number or operator
*
* return true if expression is balanced
* return false otherwise
*/
bool isBalanced(string expression);
/*
* Converts a postfix expression into an infix expression
* and returns the infix expression.
*
* - The given postfix expression will have a space between every number or operator.
* - The returned infix expression must have a space between every number or operator.
* - Redundant parentheses are acceptable i.e. ( ( 3 * 4 ) + 5 ).
* - Check lab requirements for what will be considered invalid.
*
* return the string "invalid" if postfixExpression is not a valid postfix expression.
* otherwise, return the correct infix expression as a string.
*/
string postfixToInfix(string postfixExpression);
/*
* Evaluates a postfix expression returns the result as a string
*
* - The given postfix expression will have a space between every number or operator.
* - Check lab requirements for what will be considered invalid.
*
* return the string "invalid" if postfixExpression is not a valid postfix Expression
* otherwise, return the correct evaluation as a string
*/
string postfixEvaluate(string postfixExpression);
/*
* Converts an infix expression into a postfix expression
* and returns the postfix expression
*
* - The given infix expression will have a space between every number or operator.
* - The returned postfix expression must have a space between every number or operator.
* - Check lab requirements for what will be considered invalid.
*
* return the string "invalid" if infixExpression is not a valid infix expression.
* otherwise, return the correct postfix expression as a string.
*/
string infixToPostfix(string infixExpression);
};