|
|
@ -1,25 +1,36 @@ |
|
|
|
import com.google.gson.Gson; |
|
|
|
import java.io.FileWriter; |
|
|
|
import java.io.IOException; |
|
|
|
import java.util.UUID; |
|
|
|
|
|
|
|
public class SignUp { |
|
|
|
private String id; |
|
|
|
private String userName; |
|
|
|
private String password; |
|
|
|
private String birthday; |
|
|
|
|
|
|
|
// Constructor |
|
|
|
public SignUp(String name, String password, String birthday) { |
|
|
|
this.userName = name; |
|
|
|
public SignUp(String id, String name, String password, String birthday) { |
|
|
|
this.id = id; |
|
|
|
this.userName = name; |
|
|
|
this.password = password; |
|
|
|
this.birthday = birthday; |
|
|
|
} |
|
|
|
|
|
|
|
// Getters and Setters |
|
|
|
public String getId() { |
|
|
|
return id; |
|
|
|
} |
|
|
|
|
|
|
|
public void setId(String id) { |
|
|
|
this.id = id; |
|
|
|
} |
|
|
|
|
|
|
|
public String getUserName() { |
|
|
|
return userName; |
|
|
|
} |
|
|
|
|
|
|
|
public void setName(String userName) { |
|
|
|
public void setUserName(String userName) { |
|
|
|
this.userName = userName; |
|
|
|
} |
|
|
|
|
|
|
@ -40,7 +51,7 @@ public class SignUp { |
|
|
|
} |
|
|
|
|
|
|
|
// Function to create user with validation |
|
|
|
public static SignUp createUser(String userName, String password, String birthday) { |
|
|
|
public static SignUp createUser(String id, String userName, String password, String birthday) { |
|
|
|
if (userName == null || userName.isEmpty()) { |
|
|
|
throw new IllegalArgumentException("Username cannot be empty"); |
|
|
|
} |
|
|
@ -49,7 +60,7 @@ public class SignUp { |
|
|
|
} |
|
|
|
if (password.length() < 6) { |
|
|
|
throw new IllegalArgumentException("Password must be at least 6 characters long"); |
|
|
|
} return new SignUp(userName, password, birthday); |
|
|
|
} return new SignUp(id, userName, password, birthday); |
|
|
|
} |
|
|
|
|
|
|
|
// Function to save to JSON file, replace with database call later |
|
|
@ -66,9 +77,11 @@ public class SignUp { |
|
|
|
public static void main(String[] args) { |
|
|
|
try { |
|
|
|
// Example usage |
|
|
|
SignUp user = createUser("Test User", "TestPasswort", "01.01.1900"); |
|
|
|
UUID randomUUID = UUID.randomUUID(); |
|
|
|
SignUp user = createUser(randomUUID.toString(), "Test User", "TestPasswort", "01.01.1900"); |
|
|
|
|
|
|
|
// Example of accessing properties |
|
|
|
System.out.println("UserID: " + user.getId()); |
|
|
|
System.out.println("User Name: " + user.getUserName()); |
|
|
|
System.out.println("User Password: " + user.getPassword()); |
|
|
|
System.out.println("User Birthday: " + user.getBirthday()); |
|
|
|