0

I have to implement my own exception (a GameException) which is thrown by the alpha beta algorithm in a nullsumm game. Is this correct?

import java.lang.Exception;

 public class GameException extends Exception { 

     public static final long serialVersionUID = 3654258946527845L;

     public static final String NoValidMoves = "There are noe valid moves!";


    GameException(String Message) {
        super(Message);
    }
    GameException() {

    }

}
1
  • I think your code is correct. In addtion to, you may add some custom methods for your exception class. For exaple; you throw an error code and your method matches the error code explanation and return it for exception message. Good luck ! Commented Mar 8, 2014 at 8:13

1 Answer 1

3

It's correct.


FYI

  • You don't need to import java.lang.Exception. The java.lang part means that it is there by default.
  • By convention, variables in Java are lowerCamelCase.
  • You don't need to make serialVersionUID public. Any access modifier will work with Serializable, so usually private is chosen.
  • You misspelled "no".
Sign up to request clarification or add additional context in comments.

1 Comment

it is calling the no-arg constructor : stackoverflow.com/questions/2054022/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.