Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Users.java
- public Users(int id, String username, String password, String email) {
- this.id = id;
- this.username = username;
- this.password = password;
- this.email = email;
- this.projectsMap = new HashMap<>();
- }
- private int id;
- private String username;
- private String password;
- private String email;
- private boolean enabled = true;
- private Map<Integer, List<Projects>> projectsMap;
- //getter method
- Projects.java:
- private int id;
- private String title;
- private String description;
- private Date createDate;
- private Date finishDate;
- public Projects(int id, String title, String description, Date createDate, Date finishDate) {
- this.id = id;
- this.title = title;
- this.description = description;
- this.createDate = createDate;
- this.finishDate = finishDate;
- }
- //getter method
- Main.java
- List<Users> usersList = new ArrayList<>();
- Users user = new Users(1, "user1", "12345", "user1@mail.ru");
- Users user2 = new Users(2, "user2", "123", "user2@mail.ru");
- Date today = new Date();
- Projects project = new Projects(1, "project1", "project1Description", today, today);
- user.addProject(user.getId(), project);
- usersList.add(user);
- usersList.add(user2);
- for (Users u : usersList) {
- System.out.println(u.getUsername() + " project *************");
- for (Map.Entry<Integer, List<Projects>> entry : u.getProjectsMap().entrySet()) {
- if (entry.getKey() == user.getId()) {
- System.out.println(entry.getValue().get(0).getDescription());
- }
- }
- System.out.println(u.getPassword());
- System.out.println("***********************************");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement