Due Monday, November 30 at 11:59 PM
By the time you have completed this work, you should be able to:
try, throw, and throws)catch)InvalidNumberException.javaNumberValidator.javaPositiveNumber.javaNonNegativeNumber.javaNumberValidatorMain.javacollaborators.txt
Download all the provided .java files under the Provided files listing above.
InvalidNumberException.java
You will need to define a custom class.
The comments in InvalidNumberException.java provide more details.
NumberValidator.java
You will need to define a custom abstract class.
The comments in NumberValidator.java provide more details.
PositiveNumber.java
You will need to define a custom class.
The comments in PositiveNumber.java provide more details.
NonNegativeNumber.java
You will need to define a custom class.
The comments in NonNegativeNumber.java provide more details.
NumberValidatorMain.java
Run the main method in NumberValidatorMain.java.
This code takes two command-line arguments:
If a number cannot be parsed, it will output an appropriate error message, depending on what was wrong.
For example, underneath the command-line arguments 2 3 this will produce the following output:
Parsed and valid: 2 Parsed and valid: 3
As another example, the following is the output for the command-line arguments foo -1:
java.lang.NumberFormatException: For input string: "foo" Is negative: -1
As a third example, the following is the output for the command-line arguments 0 0:
Not positive: 0 Parsed and valid: 0
Log into Canvas, and go to the COMP 110L class. Click “Assignments” on the left pane, then click “Lab 21”. From here, you can upload your code. Specifically, you must turn in the following four files:
InvalidNumberException.javaNumberValidator.javaPositiveNumber.javaNonNegativeNumber.java
In addition, if you collaborated with anyone else, be sure to download collaborators.txt
and write the names of the people you collaborated with in the file, one per line. Please submit this file along with the other files.
You can turn in the assignment multiple times, but only the last version you submitted will be graded.