Group.java 986 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package analyzer.models;
  2. import java.util.ArrayList;
  3. import java.util.Hashtable;
  4. import java.util.List;
  5. import java.util.Map;
  6. public class Group {
  7. private int id;
  8. private List<Client> clients = new ArrayList<>();
  9. private final Map<Round, Integer> roundMap;
  10. public Group(int id) {
  11. this.id = id;
  12. roundMap = new Hashtable<>();
  13. }
  14. public void addClient(Client c) {
  15. if(!clients.contains(c)) {
  16. this.clients.add(c);
  17. c.setGroup(this);
  18. }
  19. c.getRounds().forEach((k, v) -> {
  20. Integer value = roundMap.get(k);
  21. if(value == null)
  22. roundMap.put(k, v);
  23. else {
  24. if(v > value)
  25. roundMap.replace(k, v);
  26. }
  27. });
  28. }
  29. public List<Client> clients(){
  30. return clients;
  31. }
  32. public int getId() {
  33. return id;
  34. }
  35. public Map<Round, Integer> getRounds() {
  36. return roundMap;
  37. }
  38. }