forked from osterholt/scrum-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColumn.java
126 lines (114 loc) · 3.21 KB
/
Column.java
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import java.util.ArrayList;
import java.util.UUID;
import java.time.LocalDateTime;
/**
* @author Evelyn Ellis
* @version v1.0
* Date: 10/12/2023
*/
public class Column {
private String title;
private String description;
private ArrayList<Task> tasks;
public Column(String title) {
init(title, null);
}
public Column(String title, String description){
init(title, description);
}
private void init(String title, String description) {
setTitle(title);
setDescription(description);
tasks = new ArrayList<Task>();
}
public boolean setDescription(String description){
if(description == null)
return false;
this.description = description;
return true;
}
public boolean addTask(UUID id, String name, String description, LocalDateTime time, User author, User assignee, Category category, boolean resolved, int priority, float timeRequired){
Task newTask = new Task(id, name, description, time, author, assignee, category, resolved, priority, timeRequired);
return addTask(newTask);
}
public boolean addTask(Task task) {
for(Task currTask : tasks) {
if(currTask.equals(task))
return false;
}
tasks.add(task);
return true;
}
public boolean addTask(String name){
for(Task currTask : tasks) {
if(currTask.getName().equals(name))
return false;
}
Task newTask = new Task(name);
addTask(newTask);
return true;
}
public boolean setTitle(String title){
if(title == null)
return false;
this.title = title;
return true;
}
public boolean taskReorder(int index, Task task){
//sb
if(index >= 0 && index < tasks.size()) {
tasks.add(index, task);
return true;
}
return false;
}
public Task getTask(UUID id) {
for(Task task : tasks) {
if(task.getID().equals(id))
return task;
}
return null;
}
public Task getTask(String name) {
for(Task task : tasks) {
if(task.getName().equals(name))
return task;
}
return null;
}
public boolean removeTask(String name) {
for(Task task : tasks) {
if(task.getName().equals(name)) {
tasks.remove(task);
return true;
}
}
return false;
}
public ArrayList<Task> getTasks() {
return tasks;
}
/**
* Returns title of the column.
* @return String representing the title.
* @autor Cam Osterholt
*/
public String getTitle() {
return title;
}
public String getDescription() {
return description;
}
public String toString(){
String toReturn = "\n Title: " +title;
if(description!=null)
toReturn += "\n Description: " + description;
if(tasks!=null){
toReturn += "\n Tasks: ";
for(int i = 0; i < tasks.size(); i++){
toReturn += tasks.get(i).toString();
}
}
return toReturn;
}
}