|
|
@ -27,13 +27,20 @@ public class SignUp { |
|
|
|
|
|
|
|
// Function to create user |
|
|
|
public static SignUp createUser(String name, String password) { |
|
|
|
// add validation logic here |
|
|
|
return new SignUp(name, password); |
|
|
|
if (name == null || name.isEmpty()) { |
|
|
|
throw new IllegalArgumentException("Username cannot be empty"); |
|
|
|
} |
|
|
|
if (password == null || password.isEmpty()) { |
|
|
|
throw new IllegalArgumentException("Password cannot be empty"); |
|
|
|
} |
|
|
|
if (password.length() < 6) { |
|
|
|
throw new IllegalArgumentException("Password must be at least 6 characters long"); |
|
|
|
} return new SignUp(name, password); |
|
|
|
} |
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
// Example |
|
|
|
SignUp user = createUser("JohnDoe", "password123"); |
|
|
|
SignUp user = createUser("TestUser", "TestPasswort"); |
|
|
|
|
|
|
|
// Example of accessing properties |
|
|
|
System.out.println("User Name: " + user.getName()); |
|
|
|