Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. public class FreeMember extends Member {
  2. public int FREE_PRIVATE_REPOS = 3;
  3. public int numPrivateRepo = 0;
  4.  
  5. FreeMember(String email, String password) {
  6. super(email, password);
  7. }
  8.  
  9. @Override
  10. public Boolean addRepository(Repository repo) {
  11. if (repo.isPrivate()) {
  12. if (this.getNumPrivateRepo() == this.FREE_PRIVATE_REPOS) {
  13. System.out.println("Name: " + repo.getName()
  14. + " (PRIVATE) cannot be added because the number of private repository is reaching the limit");
  15. return false;
  16. } else {
  17. this.repoList.add(repo);
  18. this.numPrivateRepo++;
  19. return true;
  20. }
  21. } else {
  22. this.repoList.add(repo);
  23. return true;
  24. }
  25.  
  26. }
  27.  
  28. public int getNumPrivateRepo() {
  29. return this.numPrivateRepo;
  30. }
  31.  
  32. @Override
  33. public Boolean removeRepository(Repository repo) {
  34. for (int i = 0; i < this.repoList.size(); i++) {
  35. if (this.repoList.get(i).isPrivate() && this.repoList.get(i).isEqual(repo)) {
  36. this.repoList.remove(i);
  37. this.numPrivateRepo--;
  38. return true;
  39. }
  40. }
  41. return false;
  42.  
  43. }
  44.  
  45. @Override
  46. public void printMemberInfo() {
  47. System.out.println("--- FREE MEMBER ---");
  48. System.out.println("Email" + this.email + "(pwd: " + this.password + ")");
  49. for (Repository repo : this.repoList) {
  50. if (repo.isPrivate()) {
  51. System.out.println("Name: " + repo.getName() + "(Private)");
  52. } else {
  53. System.out.println("Name: " + repo.getName() + "(Public)");
  54. }
  55.  
  56. }
  57.  
  58. }
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement