Advertisement
SpringLightking

parse.java

May 24th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. Users.java
  2. public Users(int id, String username, String password, String email) {
  3. this.id = id;
  4. this.username = username;
  5. this.password = password;
  6. this.email = email;
  7. this.projectsMap = new HashMap<>();
  8. }
  9. private int id;
  10. private String username;
  11. private String password;
  12. private String email;
  13. private boolean enabled = true;
  14. private Map<Integer, List<Projects>> projectsMap;
  15. //getter method
  16.  
  17. Projects.java:
  18.  
  19. private int id;
  20. private String title;
  21. private String description;
  22. private Date createDate;
  23. private Date finishDate;
  24. public Projects(int id, String title, String description, Date createDate, Date finishDate) {
  25. this.id = id;
  26. this.title = title;
  27. this.description = description;
  28. this.createDate = createDate;
  29. this.finishDate = finishDate;
  30. }
  31. //getter method
  32.  
  33. Main.java
  34. List<Users> usersList = new ArrayList<>();
  35.  
  36. Users user = new Users(1, "user1", "12345", "user1@mail.ru");
  37. Users user2 = new Users(2, "user2", "123", "user2@mail.ru");
  38. Date today = new Date();
  39. Projects project = new Projects(1, "project1", "project1Description", today, today);
  40. user.addProject(user.getId(), project);
  41. usersList.add(user);
  42. usersList.add(user2);
  43. for (Users u : usersList) {
  44. System.out.println(u.getUsername() + " project *************");
  45. for (Map.Entry<Integer, List<Projects>> entry : u.getProjectsMap().entrySet()) {
  46. if (entry.getKey() == user.getId()) {
  47. System.out.println(entry.getValue().get(0).getDescription());
  48. }
  49. }
  50. System.out.println(u.getPassword());
  51. System.out.println("***********************************");
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement