Class CheckPassword


  • public class CheckPassword
    extends java.lang.Object
    A class that validates a password based on rules.

    The provided code is incomplete. Modify it so that it works properly and passes the tests in CheckPasswordTest.java.

    See Also:
    MP2 Documentation
    • Constructor Summary

      Constructors 
      Constructor Description
      CheckPassword()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean checkAPassword(java.lang.String password, int minLength, int minCapitalLetter, int minNumber, int minSpecial)
      Given a potential password check it against provided rules.
      static void main(java.lang.String[] unused)
      Solicits two strings from the user and print if they are anagrams.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CheckPassword

        public CheckPassword()
    • Method Detail

      • checkAPassword

        public static boolean checkAPassword(java.lang.String password,
                                             int minLength,
                                             int minCapitalLetter,
                                             int minNumber,
                                             int minSpecial)
        Given a potential password check it against provided rules.

        The function is passed a length and capital letter, number, and special character counts. It should return true if the password is the appropriate length and has the required number of capital letters, numbers, and special characters, and false otherwise. !,@,#,$,%,^,_, and * count as special characters.

        The counts may be zero, in which case there are no requirements for that rule. For example, if numberCount == 0 then the password does not have to contain a number. Of course, it still can.

        The passed password string may be empty but will not be null.

        Parameters:
        password - the password to check
        minLength - the minimum length for the password
        minCapitalLetter - the minimum number of capital letters the password must contain
        minNumber - the minimum number of numbers that the password must contain
        minSpecial - the minimum number of special characters that the password must contain
        Returns:
        true if the password follows the rules, false otherwise
      • main

        public static void main(java.lang.String[] unused)
        Solicits two strings from the user and print if they are anagrams.

        You are free to review this function, but should not modify it. Note that this function is not tested by the test suite, as it is purely to aid your own interactive testing.

        Parameters:
        unused - unused input arguments