Challenge: Guard Clauses in User Registration
Завдання
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.".
Рішення
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 2. Розділ 4
single
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат
Suggested prompts:
Can you explain this in simpler terms?
What are some examples related to this topic?
How does this information apply to real-world situations?
Чудово!
Completion показник покращився до 4.17
Challenge: Guard Clauses in User Registration
Свайпніть щоб показати меню
Завдання
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.".
Рішення
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 2. Розділ 4
single