-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask.js
More file actions
130 lines (125 loc) · 2.78 KB
/
task.js
File metadata and controls
130 lines (125 loc) · 2.78 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
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
127
128
129
130
const { getDiffieHellman } = require("crypto");
const { get } = require("http");
class task
{
constructor(name, info, time, frequency, expireDate)
{
this.name = name; //Display name of task
this.info = info;
this.time = time;
this.frequency = frequency;
this.expireDate = expireDate;
}
getName()
{
return this.name;
}
getInfo()
{
return this.info;
}
getTime()
{
return this.time;
}
getFrequency()
{
return this.frequency;
}
getExpireDate()
{
return this.expireDate;
}
setName(newName)
{
this.name = newName
}
setInfo(newInfo)
{
this.info = newInfo
}
setTime(newTime)
{
this.time = newTime;
}
setFrequency(newFreq)
{
this.frequency = newFreq
}
setExpireDate(newExp)
{
this.expireDate = newExp
}
}
class tasks
{
constructor()
{
this.tasks = []
}
fromSaveString(saveString)
{
this.tasks = [];
var listTasks = saveString.split("?");
for (let i = 0; i < listTasks.length - 1; i++)
{
var taskData = listTasks[i].split("-")
if (taskData.length != 5)
{
console.log("Invalid task on index: " + i)
for (let j = 0; j < taskData.length; j++)
{
console.log(taskData[j])
}
return -1;
}
this.tasks[i] = new task(taskData[0], taskData[1], taskData[2], taskData[3], taskData[4]);
}
}
addTask(name, info, time, frequency, expireDate)
{
var temp = new task(name, info, time, frequency, expireDate);
this.tasks.push(temp);
return temp;
}
length()
{
return this.tasks.length;
}
getTask(id)
{
return this.tasks[id];
}
getidByName(name)
{
for(let i = 0; i < this.length; i++)
{
if (name.includes(this.tasks[id].getName))
{
return i;
}
}
}
replaceTask(id, name, info, time, frequency, expireDate)
{
this.tasks[id] = new task(name, info, time, frequency, expireDate);
}
removeTask(name)
{
this.tasks.splice(getidByName(name), 1)
}
toString()
{
var outString = "";
for(let i = 0; i < this.tasks.length; i++)
{
outString = outString +
this.tasks[i].getName() + "-" +
this.tasks[i].getInfo() + "-" +
this.tasks[i].getTime() + "-" +
this.tasks[i].getFrequency() + "-" +
this.tasks[i].getExpireDate() + '?';
}
return outString;
}
}