-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChannel.java
More file actions
52 lines (41 loc) · 1.31 KB
/
Channel.java
File metadata and controls
52 lines (41 loc) · 1.31 KB
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
51
package org.cis120;
import java.util.*;
public class Channel {
private String owner;
private boolean isPrivate;
private TreeSet<String> usersInChannel;
public Channel(String own) {
usersInChannel = new TreeSet<>();
owner = own;
usersInChannel.add(owner);
isPrivate = false;
}
public Channel(String own, Boolean invite) {
usersInChannel = new TreeSet<>();
owner = own;
usersInChannel.add(owner);
isPrivate = invite;
}
public TreeSet<String> getUsers() {
TreeSet<String> newUsers = usersInChannel;
return newUsers;
} //returns the users in the Channel
public String getOwner() {
return owner;
} //returns the owner of the Channel
public void changeOwnerName(String name) {
owner = name;
} //changes the name of the owner
public boolean privateState() {
return isPrivate;
} //returns the state of the Channel (public or private)
public void addUser(String user) {
usersInChannel.add(user);
} //adds user to the Channel
public void removeUser(String user) {
usersInChannel.remove(user);
} //removes user from the Channel
public void removeAllUsers() {
usersInChannel = new TreeSet<>();
} //removes all users from the Channel
}