-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsprint.js
40 lines (36 loc) · 1.05 KB
/
sprint.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
/* Sprint
* a list of the activities for a particular time period
* can add items and remove items from the list;
* also keeps separate lists of current items and completed items
*
*/
var Sprint = function(startDate, endDate){
this.startDate = startDate;
this.endDate = endDate;
this.items = []
this.completedItems = [];
}
//add an item to the present list
Sprint.prototype.addItem(item){
this.items.push(item);
item.setSprint = this;
}
//remove an item from the present list
Sprint.prototype.removeItem(item){
this.items[this.items.indexOf(item)] = null;
}
//adds item to a completed item list and removes it from the present list
Sprint.prototype.completeItem(item){
//add a new item to the completed item list
this.completedItems.push(this.items[this.items.indexOf(item)]);
//and remove it from the present itemList
this.removeItem(item);
}
//returns present list
Sprint.prototype.getItems = function(){
return items();
}
//returns completed list
Sprint.prototype.getCompletedItems = function(){
return completedItems();
}