-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path99_TaskManage.sol
More file actions
62 lines (48 loc) · 1.43 KB
/
Copy path99_TaskManage.sol
File metadata and controls
62 lines (48 loc) · 1.43 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
// SPDX-License-Identifier:MIT
pragma solidity ^0.8.0;
contract TaskContract {
// Type Declarations
enum Status {
New,
InProgress,
Closed
}
struct Task {
address assignee;
string description;
Status status;
}
address public owner;
// Task 1 - Index out of Range
// Check in taskInprogress, taskClosed, getTaskDetails
// whether the index provided as input is within the range of values acceptable
// Task 1.5 - Throw Error
// If index is out of range throw Error Message "Index out of Range"
// Task 2 - Set an owner to this contract
// Task 3 - Use Modifier whether necessary to optimize code.
constructor() {
owner = msg.sender;
}
modifier indexRange(uint index) {
require(index < taskManager.length, "Index out of Range");
_;
}
Task[] public taskManager;
function addNewTask(address asign, string memory desc) public {
taskManager.push(Task(asign, desc, Status.New));
}
function taskInprogress(uint index) public indexRange(index) {
taskManager[index].status = Status.InProgress;
}
function getTaskDetails(uint index)
public
view
indexRange(index)
returns (Task memory)
{
return taskManager[index];
}
function taskClosed(uint index) public indexRange(index) {
taskManager[index].status = Status.Closed;
}
}