0

I have to implement the alpha beta prunning algorithm for the game 4Connect. I have to implement the method with generics:

public M getBestMove() throws GameException {

I don't really know what the statement "throws GameException" means. I tried to write my own exception. but I never did it before, so I could need some help from you

  • possible duplicate of [How to define custom exception class in Java, the easiest way?](http://stackoverflow.com/questions/3776327/how-to-define-custom-exception-class-in-java-the-easiest-way) – Bernhard Barker Mar 08 '14 at 10:52

1 Answers1

0

Do I need a try catch block in my method?

No, since your method throws an exception the client code, the code that calls this method, needs it in a try block.

try{
    Move m = getBestMove();
}catch(GameException e){
    //handle the exception
}

To answer your other question, you can do whatever you want after you catch the exception, so you can turn the game back on if you want.

nook
  • 2,378
  • 5
  • 34
  • 54
  • thank you, but do I have to throw the game exception in the method by my self? and can you have a llok over my exception? I don`t think its right. – user3336368 Mar 08 '14 at 07:56