diff --git a/src/main/java/SignUp.java b/src/main/java/SignUp.java index fe9ada6..79e32a8 100644 --- a/src/main/java/SignUp.java +++ b/src/main/java/SignUp.java @@ -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 @@ -65,10 +76,12 @@ public class SignUp { public static void main(String[] args) { try { - // Example usage - SignUp user = createUser("Test User", "TestPasswort", "01.01.1900"); + // Example usage + 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()); diff --git a/user.json b/user.json index b8726e5..5232e18 100644 --- a/user.json +++ b/user.json @@ -1 +1 @@ -{"userName":"Test User","password":"TestPasswort","birthday":"01.01.1900"} \ No newline at end of file +{"id":"48728bbb-b924-48ce-aac0-3e38d6c7878e","userName":"Test User","password":"TestPasswort","birthday":"01.01.1900"} \ No newline at end of file