Created a proper UserGroup class with attributes to get all users from array list so that the populate panel function can go through all users and populate the panels based on the total number of users

This commit is contained in:
bobbert committed 2025-04-02 13:18:13 +01:00
1 parent 8245777db1
commit 0b66878649
3 files changed
+21 -7

No files matched your search

+1 -1
View File
@@ -9,7 +9,7 @@ public class User {
private String address;
private String getUserAttribute(User user, String panelName) {
public String getUserAttribute(String panelName) {
return switch (panelName.toLowerCase()) {
case "title" -> user.getTitle();
case "name" -> user.getName();
+19 -5
View File
@@ -4,11 +4,25 @@ import java.util.ArrayList;
public class UserGroup {
private ArrayList<User> users;
private static ArrayList<User> users;
public UserGroup()
{
new ArrayList<User>();
private UserGroup() {
users = new ArrayList<>();
}
}
public static ArrayList<User> getUsers() {
return users;
}
public void addUser(User user) {
users.add(user);
}
public User getUser(int index) {
if (index >= 0 && index < users.size()) {
return users.get(index);
}
return null;
}
}