Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class FreeMember extends Member {
- public int FREE_PRIVATE_REPOS = 3;
- public int numPrivateRepo = 0;
- FreeMember(String email, String password) {
- super(email, password);
- }
- @Override
- public Boolean addRepository(Repository repo) {
- if (repo.isPrivate()) {
- if (this.getNumPrivateRepo() == this.FREE_PRIVATE_REPOS) {
- System.out.println("Name: " + repo.getName()
- + " (PRIVATE) cannot be added because the number of private repository is reaching the limit");
- return false;
- } else {
- this.repoList.add(repo);
- this.numPrivateRepo++;
- return true;
- }
- } else {
- this.repoList.add(repo);
- return true;
- }
- }
- public int getNumPrivateRepo() {
- return this.numPrivateRepo;
- }
- @Override
- public Boolean removeRepository(Repository repo) {
- for (int i = 0; i < this.repoList.size(); i++) {
- if (this.repoList.get(i).isPrivate() && this.repoList.get(i).isEqual(repo)) {
- this.repoList.remove(i);
- this.numPrivateRepo--;
- return true;
- }
- }
- return false;
- }
- @Override
- public void printMemberInfo() {
- System.out.println("--- FREE MEMBER ---");
- System.out.println("Email" + this.email + "(pwd: " + this.password + ")");
- for (Repository repo : this.repoList) {
- if (repo.isPrivate()) {
- System.out.println("Name: " + repo.getName() + "(Private)");
- } else {
- System.out.println("Name: " + repo.getName() + "(Public)");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement