-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClosedGroup.java
More file actions
50 lines (40 loc) · 924 Bytes
/
Copy pathClosedGroup.java
File metadata and controls
50 lines (40 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package PamakBook;
import java.io.Serializable;
public class ClosedGroup extends Group implements Serializable{
private static final long serialVersionUID = -3629051814124279721L;
//Constructor
public ClosedGroup(String name, String description)
{
super(name, description);
}
//add users to closed group. Override addMember of Group class
public void addMember(User user)
{
boolean flag = false;
if (this.getMembers().isEmpty())
{
flag = true;
}
else
{
for(User m : this.getMembers())
{
if(user.isFriend(m)) //check if user is a friend of a member in the group
{
flag = true;
break;
}
}
}
if(flag)
{
super.addMember(user); //apply the addMember from the Group class
}
/* else
{
System.out.println("FAILED: "+ user.getName() +" cannot be enrolled in group " + this.getName());
}
*/
}
}
//Artemis Dara-2025