Hello, I'm doing a project in java that involves stacks and queues, but that's fine, but among some conditionals I did with if one of them "presented" an error (Actually do not present or do what he should do is the "error" in question ...
Follow the source code below
try
{
String equa = txtEqua.getText();
StringTokenizer quebratuto = new StringTokenizer(equa,"+-*/^()",true);
Pilha p = new Pilha(quebratuto.countTokens());
Fila f = new Fila(quebratuto.countTokens());
TabelaDePrecedencias table = new TabelaDePrecedencias();
while (quebratuto.hasMoreTokens())
{
String token = quebratuto.nextToken();
char topo = ' ';
char sequencia = ' ';
try
{
Double nro = Double.parseDouble(token);
f.guardeUmItem(nro);
}
catch(NumberFormatException erro)
{
if (token == "(") //não está entrando neste cara aqui :/
{
p.guardeUmItem(token);
continue;
}
if(p.vazia())
{
p.guardeUmItem(token);
continue;
}
sequencia = token.charAt(0);
teste2.setText(sequencia+"Sequencia");
topo = (char)p.getUmItem();
teste3.setText((char)topo+"Topo");
Boolean devoDesenpi = table.devoDesempilhar(topo,sequencia);
if(devoDesenpi==true && sequencia == ')')
{
teste2.setText(devoDesenpi.toString());
char salvaItem = (char)p.getUmItem();
while (salvaItem != '(')
{
p.jogueUmItemFora();
f.guardeUmItem(salvaItem);
salvaItem = ' ';
}
if(salvaItem == '(' || salvaItem == ')')
p.jogueUmItemFora();
}
}
}
}
catch(Exception erro)
{
teste2.setText("Ta errado :/");
}