I broke my foot and missed the first part of class where this was covered now I'm all confused.
I have a password class and I must create within this class a static method of isValid
that will accept a possible password value and return if it is valid. I have to test for a. must be at least 6 characters long
b. contain at least 1 capital letter
c. contain at least 1 lowercase letter
d. contain at least 1 digit.
public class Password
{
// instance variables - replace the example below with your own
public String userPassword;
/**
* Constructor for objects of class Password
*/
public Password(String password)
{
// initialise instance variables
password = userPassword;
}
/**
* An example of a method - replace this comment with your own
*
* @param y a sample parameter for a method
* @return the sum of x and y
*/
public static boolean isValid()
{
if (userPassword == null)
{
throw new IllegalArgumentException("User password may not be null");
}
if (userPassword.length() < 6)
{
throw new IllegalArgumentException ("User password must be atleast 6 characters");
}
{
return false;
}
}
// put your code here
}
I don't know if I posted the code correctly or not, if not please let me know.
thanks for any advise