DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Java (http://www.daniweb.com/forums/forum9.html)
-   -   Error Checking for user input (http://www.daniweb.com/forums/thread31756.html)

guessvic Sep 4th, 2005 12:38 pm
Error Checking for user input
 
Hello all, is that possible to help me out with Error Checking for user input? I am developing a peg solitaire program and now need a error checking for user input or for input file.

Either use try and catch.. or making another method.. can anyone give a me a hint or help me out here please.

Regards

Easter Bunny Sep 5th, 2005 9:31 am
Re: Error Checking for user input
 
what kind of error checking? like when the user tries to put a king on a 7? you can use a method to check that and if the user is being a moron, then you can display a joptionpane or you can throw one of your own exceptions which will have to be dealt with. something like InvalidMoveException.

server_crash Sep 5th, 2005 10:52 am
Re: Error Checking for user input
 
For something like that I would say some if else statements would work. Like:

if (!card slot is already taken)
{
      //do something
}
else
{
    //do something else
}

Of course it would be cool to experiment making your own exception as EB said.

guessvic Sep 6th, 2005 8:40 am
Re: Error Checking for user input
 
Thanks for all replies. I just got it working with try and catch exception, my problem was I use try {}catch (IOException e) {} instead of just use catch (Exception e) {}

The input only reads: From <row><coloum> To <row1><coloum1>
Exception prevent any invalid input such as "jslkfjsdlkfjlkd".


All times are GMT -4. The time now is 11:07 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC