import stack.RStack;
public class Expressions {
private RStack data;
public Expressions() {
}
public boolean checkbalance(String expression) {
char charAt;
int i, len;
len = expression.length();
for(i = 0; i < len; i++) {
charAt = expression.charAt(i);
if(charAt == '(')
push(charAt);
else if(ch == ')') {
if(isEmpty())
return false;
else if((char)peek() == '(')
pop();
else
return false;
}
}
if(isEmpty())
return true;
else
return false;
}
public int precedence(char c) {
if((c == '*') || (c == '/'))
return 2;
else if((c == '+') || (c == '-'))
return 1;
else
return 0;
}
public boolean isOperand(char c) {
if((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9'))
return true;
else
return false;
}
public String infixToPostfix(String infix) {
char c;
int len, i;
String postfix = "";
len = infix.length();
for(i = 0; i < len; i++) {
c = infix.charAt(i);
if(isOperand(c))
postfix = postfix + c;
else if(c == '(')
push(c);
else if(c == ')') {
while((char)peek() != '(')
postfix = postfix + pop();
pop();
} else {
while(!isEmpty() && (precedence(c) <= precedence((char)peek())))
postfix = postfix + pop();
push(c);
}
}
while(!isEmpty())
postfix = postfix + pop();
return postfix;
}
public RStack getData() {
return data;
}
public void setData(RStack data) {
this.data = data;
}
}
Any idea on why do i always get "The method push(char) is undefined for the type Expressions", "the method peek() is undefined for the type Expressions", "The method isEmpty() is undefined for the type Expressions" and "The method pop() is undefined for the type Expressions"? when im trying to balance parenthesis for lab project and I always run into this issue