I want help in finding the number of defects in the below java piece by using unit testing.
I only found 3, but I want to make sure that I found all of them. I would really appreciate it if somebody could help me with this. Thank you. Bellow are the comments about how this piece of code should work.
// constructor
// Throws IllegalArgumentException if invalid value
// Exception message for invalid value: "One or more of the parameters have invalid value"
// t parameter can only be upper case characters: E, D, A
// n parameter must be a value between 10000 and 99999 inclusively
// p parameter must be greater than 0
// when all values are valid, assigns t to attribute type, n to attribute number and p to attribute price
Here is the script
public Cars(char t, int n, int p)
{
if (t != 'E' && t != 'D' && t != 'A')
throw new NullPointerException("One or more of the parameters have invalid value");
if (n < 10000 || n >= 99999)
throw new IllegalArgumentException("One parameter has invalid value");
if (p <= 0)
throw new IllegalArgumentException("One or more of the parameters have invalid value");
type = t;
number = n;
price = p;
}