steven
asked on
I have a java code that is not preforming what i expect to, i am very new to java.
I have the below code and I needed to add a try catch to insure proper data, the below doesn't work at all. It prompts for the blower value but if I type in an improper value it still will not "catch" the error? Please help if possible I am very new to java.
String test = " ";
boolean badInput = true;
if(race.getClass()== Hotrod.class)
{
Hotrod h =(Hotrod)race;
//test = (getInput("Blower equipped: Y/N"));
if (test.equalsIgnoreCase("y" ))
{
h.setBlower(true);
}// end if
else if (test.equalsIgnoreCase("n" ))
{
h.setBlower(false);
} //end else if
else
{
do{
try
{
test = (getInput("Blower equipped: Y/N"));
if (!test.equalsIgnoreCase("y ")|| !test.equalsIgnoreCase("n" ))
{
badInput = false;
}
}
catch (Exception ex)
{
JOptionPane.showMessageDia log(null,t est + "Please enter the proper value","Error",JOptionPane .PLAIN_MES SAGE);
}
} while(badInput);
}//end else
} //end if(race.getClass()== Hotrod.class)
String test = " ";
boolean badInput = true;
if(race.getClass()== Hotrod.class)
{
Hotrod h =(Hotrod)race;
//test = (getInput("Blower equipped: Y/N"));
if (test.equalsIgnoreCase("y"
{
h.setBlower(true);
}// end if
else if (test.equalsIgnoreCase("n"
{
h.setBlower(false);
} //end else if
else
{
do{
try
{
test = (getInput("Blower equipped: Y/N"));
if (!test.equalsIgnoreCase("y
{
badInput = false;
}
}
catch (Exception ex)
{
JOptionPane.showMessageDia
}
} while(badInput);
}//end else
} //end if(race.getClass()== Hotrod.class)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER