Advertisement
spiny94

Untitled

Sep 3rd, 2015
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.43 KB | None | 0 0
  1. package facebook;
  2. public class PersonExistsException extends Exception {
  3. }
  4. package facebook;
  5. public class NoSuchCodeException extends Exception {
  6. }
  7. import java.util.Collection;
  8. import java.util.HashSet;
  9.  
  10. public class Person {
  11.     String name;
  12.     String surname;
  13.     String code;
  14.     HashSet<String> friends = new HashSet<String>();
  15.     HashSet<String> groups = new HashSet<String>();
  16.  
  17.     public Person(String code2, String name2, String surname2) {
  18.         code = code2;
  19.         name = name2;
  20.         surname = surname2;
  21.     }
  22.  
  23.     public void addFriend(String code) {
  24.         friends.add(code);
  25.     }
  26.  
  27.     public String getName() {
  28.         return name;
  29.     }
  30.  
  31.     public String getSurname() {
  32.         return surname;
  33.     }
  34.  
  35.     public String getCode() {
  36.         return code;
  37.     }
  38.  
  39.     public String toString() {
  40.         return code + " " + name + " " + surname;
  41.     }
  42.  
  43.     public Collection<String> getFriends() {
  44.         return friends;
  45.     }
  46.  
  47.     public void addGroup(String groupName) {
  48.         groups.add(groupName);
  49.     }
  50.  
  51.     public Collection<String> getGroups() {
  52.         return groups;
  53.     }
  54. }
  55. package facebook;
  56.  
  57. import java.util.Collection;
  58. import java.util.HashSet;
  59.  
  60. public class Group {
  61.  
  62.     String name;
  63.     HashSet<String> members = new HashSet<String>();
  64.  
  65.     public Group(String groupName) {
  66.     name = groupName;
  67.     }
  68.  
  69.     public void addPerson(String codePerson) {
  70.         members.add(codePerson);
  71.     }
  72.  
  73.     public Collection<String> getMembers() {
  74.         return members;
  75.     }
  76.  
  77.     public String getName() {
  78.         return name;
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement