-
Notifications
You must be signed in to change notification settings - Fork 0
/
line11.sol
54 lines (40 loc) · 1.03 KB
/
line11.sol
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
// SPDX-License-Identifier: MIT
//SPDX-License-Idetifier: Unlicensed
// enum in solidity
pragma solidity >=0.7.0;
contract enums {
enum Action {ADD, REMOVE, UPDATE}
Action choice = Action.ADD;
Action constant defaultChoice = Action.REMOVE;
function getChoice() public view returns(Action){
return choice;
}
function getDefaultChoice() public pure returns(uint){
return uint(defaultChoice);
}
function setChoice(Action _choice) public {
choice = _choice;
}
function remove() public {
choice = Action.REMOVE;
}
function add() public {
choice = Action.ADD;
}
function update() public {
choice = Action.UPDATE;
}
}
contract enums2 {
enum size{SMALL, MEDIUM, LARGE}
size public choice = size.MEDIUM;
function setSmall() public {
choice = size.SMALL;
}
function setMedium() public {
choice = size.MEDIUM;
}
function setLarge() public {
choice = size.LARGE;
}
}