Challenge: Guard Clauses in User Registration
Tarefa
Swipe to start coding
Write a method to register a user that uses guard clauses to validate the provided username and password.
- If
usernameis null or empty, immediately throw anArgumentExceptionwith the message "Username cannot be null or empty.". - If
passwordis null or empty, immediately throw anArgumentExceptionwith the message "Password cannot be null or empty.". - If both inputs are valid, return a string in the format "User '
' registered successfully.".
Solução
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 2. Capítulo 4
single
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo
Incrível!
Completion taxa melhorada para 4.17
Challenge: Guard Clauses in User Registration
Deslize para mostrar o menu
Tarefa
Swipe to start coding
Write a method to register a user that uses guard clauses to validate the provided username and password.
- If
usernameis null or empty, immediately throw anArgumentExceptionwith the message "Username cannot be null or empty.". - If
passwordis null or empty, immediately throw anArgumentExceptionwith the message "Password cannot be null or empty.". - If both inputs are valid, return a string in the format "User '
' registered successfully.".
Solução
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 2. Capítulo 4
single