Exemplo n.º 1
0
        private static bool IsValid(PasswordCheck passwordCheck)
        {
            bool first = passwordCheck.Password.Length >= passwordCheck.First &&
                         passwordCheck.Password[passwordCheck.First - 1].ToString() == passwordCheck.Letter;

            bool second = passwordCheck.Password.Length >= passwordCheck.Second &&
                          passwordCheck.Password[passwordCheck.Second - 1].ToString() == passwordCheck.Letter;

            return(!(first && second) && (first || second));
        }
Exemplo n.º 2
0
        private static bool IsValid(PasswordCheck passwordCheck)
        {
            int occurrences = passwordCheck.Password.Count(letter => letter.ToString() == passwordCheck.Letter);

            return(occurrences >= passwordCheck.First && occurrences <= passwordCheck.Second);
        }