PROGRAMMING:Jmu-java-06 exception-04-custom exception (comprehensive)
Define the 'illegalscoreexception' exception class, which represents the exception beyond the reasonable range after the addition of scores. The exception is' checked exception ', that is, you want the exception to be caught and handled.
Define the 'illegalnameexception' exception class to represent the exception with unreasonable name setting. The exception is ` unchecked exception '`
Define the 'student' class.
**Properties:**
```
private String name;
private int score;
```
**Methods:**
```
ToString / / automatically generated
Setter / getter / / automatically generated
Modify setname / / if the first letter of the name is a number, an illegalnameexception will be thrown
Public int addScore (int score) / / if the score after bonus is < 0 or > 100, illegalscoreexception will be thrown, and the bonus will not succeed.
```
###Main method:
1. Enter 'new' to create a new student object. Then enter a line of student data in the format of 'name age', and call setname, addScore. Otherwise, jump out of the loop.
2. If setname fails, an exception will be thrown and the exception information will be printed, and then the next line will be processed.
3. If addScore is not successful, an exception will be thrown, and the exception information will be printed, and then the processing of the next line will continue. If both 2 and 3 are successful, print the student information (` toString ')
4. If there are other exceptions when parsing the student data line, print the exception information, and then continue to process the next line.
5. Scanner is also a kind of resource. I hope the program will be closed no matter whether it throws an exception or not. After closing, use 'system. Out. Println ("scanner closed")' to print the closing information
**Note: * use ` system. Out. Println (E)` Print exception information, e is the generated exception.
###Input example:
```in
new
zhang 10
new
wang 101
new
wang30
new
3a 100
new
wang 50
other
```
###Output example:
```out
Student [name=zhang, score=10]
IllegalScoreException: score out of range, score=101
java.util.NoSuchElementException
IllegalNameException: the first char of name must not be digit, name=3a
Student [name=wang, score=50]
scanner closed
```
answer:If there is no answer, please comment
Define the 'illegalnameexception' exception class to represent the exception with unreasonable name setting. The exception is ` unchecked exception '`
Define the 'student' class.
**Properties:**
```
private String name;
private int score;
```
**Methods:**
```
ToString / / automatically generated
Setter / getter / / automatically generated
Modify setname / / if the first letter of the name is a number, an illegalnameexception will be thrown
Public int addScore (int score) / / if the score after bonus is < 0 or > 100, illegalscoreexception will be thrown, and the bonus will not succeed.
```
###Main method:
1. Enter 'new' to create a new student object. Then enter a line of student data in the format of 'name age', and call setname, addScore. Otherwise, jump out of the loop.
2. If setname fails, an exception will be thrown and the exception information will be printed, and then the next line will be processed.
3. If addScore is not successful, an exception will be thrown, and the exception information will be printed, and then the processing of the next line will continue. If both 2 and 3 are successful, print the student information (` toString ')
4. If there are other exceptions when parsing the student data line, print the exception information, and then continue to process the next line.
5. Scanner is also a kind of resource. I hope the program will be closed no matter whether it throws an exception or not. After closing, use 'system. Out. Println ("scanner closed")' to print the closing information
**Note: * use ` system. Out. Println (E)` Print exception information, e is the generated exception.
###Input example:
```in
new
zhang 10
new
wang 101
new
wang30
new
3a 100
new
wang 50
other
```
###Output example:
```out
Student [name=zhang, score=10]
IllegalScoreException: score out of range, score=101
java.util.NoSuchElementException
IllegalNameException: the first char of name must not be digit, name=3a
Student [name=wang, score=50]
scanner closed
```
answer:If there is no answer, please comment