InvalidCategoryException.java Requirements and Design: InvalidCategoryException
ID: 3695833 • Letter: I
Question
InvalidCategoryException.java Requirements and Design: InvalidCategoryException is a user defined exception created by extending the Exception class. This exception is to be thrown and caught in the readPlayerFile method in the SoftballTeam class when a line of input data contains an invalid player category. The constructor for InvalidCategoryException takes a single String parameter representing category and invokes the super constructor with the following String: "For category: " + """ + category + """ This string will be the toString() value of an InvalidCategoryException when it occurs.
Explanation / Answer
Hello there ,
Please find below code for InvalidCategoryException .
Let me know if you have any doubts.
Thanks.
/**
* It represents the custom exception class for invalid player category.
*
* @author dipal.prajapati
*
*/
public class InvalidCategoryException extends Exception {
/**
*
*/
private String message = null;
private static final long serialVersionUID = 1L;
public InvalidCategoryException(String category) {
super("For category: " + """ + category + """);
this.message = "For category: " + """ + category + """;
}
@Override
public String toString() {
return message;
}
@Override
public String getMessage() {
return message;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.