-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathroom.js
44 lines (38 loc) · 898 Bytes
/
room.js
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
function Room(id, owner) {
this.id = id;
this.people = [];
this.owner = owner;
this.status = "available";
};
Room.prototype.addPerson = function(personID) {
if (this.status === "available") {
this.people.push(personID);
}
};
Room.prototype.removePerson = function(person) {
var personIndex = -1;
for(var i = 0; i < this.people.length; i++){
if(this.people[i].id === person.id){
personIndex = i;
break;
}
}
this.people.remove(personIndex);
};
Room.prototype.getPerson = function(personID) {
var person = null;
for(var i = 0; i < this.people.length; i++) {
if(this.people[i].id == personID) {
person = this.people[i];
break;
}
}
return person;
};
Room.prototype.isAvailable = function() {
return this.available === "available";
};
Room.prototype.isPrivate = function() {
return this.private;
};
module.exports = Room;