コード例 #1
0
 public void createContact(String login, String firstName, String lastName, LocalDate birthDate) {
   // contact = new Contact(login, firstName, lastName, birthDate);
   if (contactDao.getContactMap().containsKey(login)) {
     System.out.println("This login isn't unique! Enter unique login");
   } else {
     contact.setLogin(login);
   }
   contact.setFirstName(firstName);
   contact.setLastName(lastName);
   contact.setBirthDate(birthDate);
   contactDao.addContact(contact);
 }
コード例 #2
0
 public Set<Contact> getFriendList(Contact contact) {
   Set<Contact> friendSet = new HashSet<>();
   Map<String, Friends> friendsMap = contactDao.getFriendshipMap();
   ArrayList<Friends> friendsList = (ArrayList<Friends>) friendsMap.values();
   for (Friends friends : friendsList) {
     if (friends.getFriendFrom().equals(contact)) {
       friendSet.add(friends.getFriendTo());
     }
     if (friends.getFriendTo().equals(contact)) {
       friendSet.add(friends.getFriendFrom());
     }
     if (!friends.getFriendFrom().equals(contact) && !friends.getFriendTo().equals(contact)) {
       System.out.println("I'm alone(Teach-In)");
     }
   }
   return friendSet;
 }
コード例 #3
0
 public void addFriendship(Contact contactFrom, Contact contactTo) {
   contactDao.addFriendship(contactFrom, contactTo);
 }